com.ninja_squad.dbsetup.generator
Class ValueGenerators

java.lang.Object
  extended by com.ninja_squad.dbsetup.generator.ValueGenerators

public final class ValueGenerators
extends java.lang.Object

Utility class containing factory methods for ValueGenerator


Method Summary
static
<T> ValueGenerator<T>
constant(T constant)
          Returns a value generator which always returns the same, given value.
static DateSequenceValueGenerator dateSequence()
          Returns a value generator that returns a sequence of dates, starting at a given date and incremented by a given time, specified as an increment and a calendar field.
static SequenceValueGenerator sequence()
          Returns a value generator which generates a sequence of long values starting with 1, with an increment of 1.
static StringSequenceValueGenerator stringSequence(java.lang.String prefix)
          Returns a value generator that returns a string prefix followed by a sequence number, optionally left-padded with 0 to ensure a correct ordering (for example: CODE_001, CODE_002, etc.).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sequence

public static SequenceValueGenerator sequence()
Returns a value generator which generates a sequence of long values starting with 1, with an increment of 1. The starting value and increment can be customized using
     ValueGenerators.increment().startingAt(1000).incrementingBy(5)
 


constant

public static <T> ValueGenerator<T> constant(@Nullable
                                             T constant)
Returns a value generator which always returns the same, given value.


stringSequence

public static StringSequenceValueGenerator stringSequence(@Nonnull
                                                          java.lang.String prefix)
Returns a value generator that returns a string prefix followed by a sequence number, optionally left-padded with 0 to ensure a correct ordering (for example: CODE_001, CODE_002, etc.). The returned generator starts the sequence at 1 and increments by 1, and doesn't pad the numbers.

Parameters:
prefix - the prefix before the generated number (for example: "CODE_").

dateSequence

public static DateSequenceValueGenerator dateSequence()
Returns a value generator that returns a sequence of dates, starting at a given date and incremented by a given time, specified as an increment and a calendar field. The returned generator starts today at 00:00:00 and increments by 1 day by default.