com.ninja_squad.dbsetup.generator
Class SequenceValueGenerator

java.lang.Object
  extended by com.ninja_squad.dbsetup.generator.SequenceValueGenerator
All Implemented Interfaces:
ValueGenerator<java.lang.Long>

public final class SequenceValueGenerator
extends java.lang.Object
implements ValueGenerator<java.lang.Long>

A ValueGenerator which generates a sequence of long values. By default, the sequence starts at 1 and increments by 1, but this can be customized. Instances of this class are created using ValueGenerators.sequence().


Method Summary
 SequenceValueGenerator incrementingBy(int increment)
          Increments the value by the given increment.
 java.lang.Long nextValue()
          Called each time a new row is inserted, to get the value to insert in the column using this value generator.
 SequenceValueGenerator startingAt(long start)
          Restarts the sequence at the given value
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

startingAt

public SequenceValueGenerator startingAt(long start)
Restarts the sequence at the given value

Parameters:
start - the starting value of the created generator
Returns:
this instance, for chaining

incrementingBy

public SequenceValueGenerator incrementingBy(int increment)
Increments the value by the given increment.

Returns:
this instance, for chaining

nextValue

public java.lang.Long nextValue()
Description copied from interface: ValueGenerator
Called each time a new row is inserted, to get the value to insert in the column using this value generator.

Specified by:
nextValue in interface ValueGenerator<java.lang.Long>
Returns:
the value to insert in the column associated with this generator.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object