Class Chronology.Builder<T extends ChronoEntity<T>>

java.lang.Object
net.time4j.engine.Chronology.Builder<T>
Type Parameters:
T - generic type of time context
Direct Known Subclasses:
CalendarFamily.Builder, TimeAxis.Builder
Enclosing class:
Chronology<T>

public static class Chronology.Builder<T extends ChronoEntity<T>> extends Object

Builder for creating a new chronology without any time axis.

This class will be used during loading of a ChronoEntity-class T in a static initializer.

Author:
Meno Hochschild
  • Method Details

    • setUp

      public static <T extends ChronoEntity<T>> Chronology.Builder<T> setUp(Class<T> chronoType, ChronoMerger<T> chronoMerger)

      Creates a builder for building a new chronological system.

      Type Parameters:
      T - generic type of time context
      Parameters:
      chronoType - chronological type
      chronoMerger - creates a new instance of T from another source (clock or parsed values)
      Returns:
      new Builder object
      Throws:
      UnsupportedOperationException - if T represents a subclass of TimePoint
    • appendElement

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

      Registers a new element together with its associated element rule.

      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
      Throws:
      IllegalArgumentException - if given element is already registered (duplicate)
    • appendExtension

      public Chronology.Builder<T> appendExtension(ChronoExtension extension)

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

      Parameters:
      extension - chronological extension
      Returns:
      this instance for method chaining
    • build

      public Chronology<T> build()

      Finishes the build of a new chronology.

      Internally the new chronology will be weakly registered for lookup(). Therefore it is strongly recommended to reference the created chronology in a static constant within the chronological type in question.

      Returns:
      new instance of chronology
      Throws:
      IllegalStateException - if already registered
      See Also:
      Chronology.lookup(Class)