Class TimeAxis.Builder<U,​T extends TimePoint<U,​T>>

java.lang.Object
net.time4j.engine.Chronology.Builder<T>
net.time4j.engine.TimeAxis.Builder<U,​T>
Type Parameters:
U - generic type of time unit
T - generic type of time context
Enclosing class:
TimeAxis<U,​T extends TimePoint<U,​T>>

public static final class TimeAxis.Builder<U,​T extends TimePoint<U,​T>> extends Chronology.Builder<T>

Creates a builder for a new time axis respective chronology and will only be used during loading a class of type TimePoint (T) in a static initializer.

Instances of this class will be created by the static factory methods setUp().

Author:
Meno Hochschild
See Also:
setUp(Class,Class,ChronoMerger,TimePoint,TimePoint), setUp(Class,Class,ChronoMerger,CalendarSystem)
  • Method Details

    • setUp

      public static <U,​ T extends TimePoint<U,​ T>> TimeAxis.Builder<U,​T> setUp(Class<U> unitType, Class<T> chronoType, ChronoMerger<T> merger, T min, T max)

      Creates a builder for building a chronological but non-calendrical system.

      Type Parameters:
      U - generic type of time unit
      T - generic type of time context
      Parameters:
      unitType - reified type of time units
      chronoType - reified chronological type
      merger - generic replacement for static creation of time points
      min - minimum value on time axis
      max - maximum value on time axis
      Returns:
      new Builder object
    • setUp

      public static <U,​ D extends Calendrical<U,​ D>> TimeAxis.Builder<U,​D> setUp(Class<U> unitType, Class<D> chronoType, ChronoMerger<D> merger, CalendarSystem<D> calendarSystem)

      Creates a builder for building a time axis for plain calendrical objects.

      Type Parameters:
      U - generic type of time unit
      D - generic type of date context
      Parameters:
      unitType - reified type of time units
      chronoType - reified chronological type
      merger - generic replacement for static creation of time points
      calendarSystem - calender system
      Returns:
      new Builder object
    • appendElement

      public <V> TimeAxis.Builder<U,​T> appendElement(ChronoElement<V> element, ElementRule<T,​V> rule)
      Description copied from class: Chronology.Builder

      Registers a new element together with its associated element rule.

      Overrides:
      appendElement in class Chronology.Builder<T extends TimePoint<U,​T>>
      Type Parameters:
      V - generic type of element value
      Parameters:
      element - chronological element to be registered
      rule - rule associated with the element
      Returns:
      this instance for method chaining
    • appendElement

      public <V> TimeAxis.Builder<U,​T> appendElement(ChronoElement<V> element, ElementRule<T,​V> rule, U baseUnit)

      Registers a new element with associated rule and a base unit.

      Type Parameters:
      V - generic type of element values
      Parameters:
      element - chronological element to be registered
      rule - associated element rule
      baseUnit - base unit for rolling operations
      Returns:
      this instance for method chaining
      Throws:
      IllegalArgumentException - if given element is already registered (duplicate)
    • appendUnit

      public TimeAxis.Builder<U,​T> appendUnit(U unit, UnitRule<T> rule, double length)

      Registers a non-convertible time unit with an associated unit rule.

      Is equivalent to appendUnit(U, rule, length, Collections.emptySet()).

      Parameters:
      unit - time unit to be registered
      rule - associated unit rule
      length - estimated standard length in seconds
      Returns:
      this instance for method chaining
      Throws:
      IllegalArgumentException - if given time unit is already registered (duplicate) or if given length does not represent any decimal number
    • appendUnit

      public TimeAxis.Builder<U,​T> appendUnit(U unit, UnitRule<T> rule, double length, Set<? extends U> convertibleUnits)

      Registers a new time unit with an associated unit rule.

      The unit rule defines the time arithmetic for addition and subtraction of given unit suitable for the time axis.

      If the unit has a length of a whole day then the given length must be equal to 86400.0. The time unit of a second has always the length 1.0.

      The default length of a time unit primarily serves for conversion purposes. Rare anomalies like leap seconds or timezone-induced jumps are not taken into account. Therefore this estimated length is usually not equal to the real length in a given time context. In case of non-convertible units the estimated length has only informational meaning. Example: Months have as length in ISO-systems the length of a gregorian year in seconds divided by 12 while in coptic calendar the divisor 13 is used. However, the definition of the length of a month in days is not suitable because months and days are not convertible.

      Convertibility exists if a time unit con be converted to another time unit using a fixed integer factor. If this is not always the case then an empty Set is to be used. Example minutes/seconds: Without an UTC-context (with possible leapseonds) minutes are convertible to seconds using a constant factor of 60. In an UTC-context however, there is no convertibility and hence the second will be missing in the argument. convertibleUnits to minutes as unit to be registered (and reverse, too)..

      Parameters:
      unit - time unit to be registered
      rule - associated unit rule
      length - estimated standard length in seconds
      convertibleUnits - other time units which unit can be converted to
      Returns:
      this instance for method chaining
      Throws:
      IllegalArgumentException - if given time unit is already registered (duplicate) or if given length does not represent any decimal number
    • appendExtension

      public TimeAxis.Builder<U,​T> appendExtension(ChronoExtension extension)
      Description copied from class: Chronology.Builder

      Registers a state extension which can create models with their own state separated from standard time value context.

      Overrides:
      appendExtension in class Chronology.Builder<T extends TimePoint<U,​T>>
      Parameters:
      extension - chronological extension
      Returns:
      this instance for method chaining
    • withTimeLine

      public TimeAxis.Builder<U,​T> withTimeLine(TimeLine<T> timeline)

      Defines the argument as timeline to be used for stepping forward or backwards.

      Parameters:
      timeline - time line to be used
      Returns:
      this instance for method chaining
      Since:
      2.0
    • build

      public TimeAxis<U,​T> build()

      Creates and registers a time axis.

      Overrides:
      build in class Chronology.Builder<T extends TimePoint<U,​T>>
      Returns:
      new chronology as time axis
      Throws:
      IllegalStateException - if already registered or in case of inconsistencies
      See Also:
      Chronology.lookup(Class)