Class TimeAxis.Builder<U,T extends TimePoint<U,T>>
- Type Parameters:
U
- generic type of time unitT
- generic type of time context
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 Summary
Modifier and TypeMethodDescription<V> TimeAxis.Builder<U,T>
appendElement(ChronoElement<V> element, ElementRule<T,V> rule)
Registers a new element together with its associated element rule.<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.appendExtension(ChronoExtension extension)
Registers a state extension which can create models with their own state separated from standard time value context.appendUnit(U unit, UnitRule<T> rule, double length)
Registers a non-convertible time unit with an associated unit rule.Registers a new time unit with an associated unit rule.build()
Creates and registers a time axis.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.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.withTimeLine(TimeLine<T> timeline)
Defines the argument as timeline to be used for stepping forward or backwards.Methods inherited from class net.time4j.engine.Chronology.Builder
setUp
-
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 unitT
- generic type of time context- Parameters:
unitType
- reified type of time unitschronoType
- reified chronological typemerger
- generic replacement for static creation of time pointsmin
- minimum value on time axismax
- 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 unitD
- generic type of date context- Parameters:
unitType
- reified type of time unitschronoType
- reified chronological typemerger
- generic replacement for static creation of time pointscalendarSystem
- calender system- Returns:
- new
Builder
object
-
appendElement
Description copied from class:Chronology.Builder
Registers a new element together with its associated element rule.
- Overrides:
appendElement
in classChronology.Builder<T extends TimePoint<U,T>>
- Type Parameters:
V
- generic type of element value- Parameters:
element
- chronological element to be registeredrule
- 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 registeredrule
- associated element rulebaseUnit
- base unit for rolling operations- Returns:
- this instance for method chaining
- Throws:
IllegalArgumentException
- if given element is already registered (duplicate)
-
appendUnit
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 registeredrule
- associated unit rulelength
- 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 length1.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 divisor13
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 of60
. 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 registeredrule
- associated unit rulelength
- estimated standard length in secondsconvertibleUnits
- other time units whichunit
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
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 classChronology.Builder<T extends TimePoint<U,T>>
- Parameters:
extension
- chronological extension- Returns:
- this instance for method chaining
-
withTimeLine
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
Creates and registers a time axis.
- Overrides:
build
in classChronology.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)
-