com.ninja_squad.dbsetup.generator
Class DateSequenceValueGenerator

java.lang.Object
  extended by com.ninja_squad.dbsetup.generator.DateSequenceValueGenerator
All Implemented Interfaces:
ValueGenerator<java.util.Date>

public final class DateSequenceValueGenerator
extends java.lang.Object
implements ValueGenerator<java.util.Date>

A ValueGenerator 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.


Nested Class Summary
static class DateSequenceValueGenerator.CalendarField
          The available units for the increment of this sequence
 
Method Summary
 DateSequenceValueGenerator incrementingBy(int increment, DateSequenceValueGenerator.CalendarField unit)
          Increments the date by the given increment of the given unit.
 java.util.Date nextValue()
          Called each time a new row is inserted, to get the value to insert in the column using this value generator.
 DateSequenceValueGenerator startingAt(java.util.Calendar startDate)
          Restarts the sequence at the given date
 DateSequenceValueGenerator startingAt(java.util.Date startDate)
          Restarts the sequence at the given date, in the default time zone
 DateSequenceValueGenerator startingAt(java.util.Date startDate, java.util.TimeZone timeZone)
          Restarts the sequence at the given date, in the given time zone
 DateSequenceValueGenerator startingAt(java.lang.String startDate)
          Restarts the sequence at the given date, in the default time zone
 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 DateSequenceValueGenerator startingAt(@Nonnull
                                             java.util.Date startDate,
                                             @Nonnull
                                             java.util.TimeZone timeZone)
Restarts the sequence at the given date, in the given time zone

Returns:
this instance, for chaining

startingAt

public DateSequenceValueGenerator startingAt(@Nonnull
                                             java.util.Date startDate)
Restarts the sequence at the given date, in the default time zone

Returns:
this instance, for chaining

startingAt

public DateSequenceValueGenerator startingAt(@Nonnull
                                             java.util.Calendar startDate)
Restarts the sequence at the given date

Returns:
this instance, for chaining

startingAt

public DateSequenceValueGenerator startingAt(@Nonnull
                                             java.lang.String startDate)
Restarts the sequence at the given date, in the default time zone

Parameters:
startDate - the starting date, as a String. The supported formats are the same as the ones supported by Binders.timestampBinder(), i.e. the formats supported by java.sql.Timestamp.valueOf() and java.sql.Date.valueOf()
Returns:
this instance, for chaining

incrementingBy

public DateSequenceValueGenerator incrementingBy(int increment,
                                                 @Nonnull
                                                 DateSequenceValueGenerator.CalendarField unit)
Increments the date by the given increment of the given unit.

Returns:
this instance, for chaining

nextValue

public java.util.Date 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.util.Date>
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