D - generic type of self referencepublic abstract class CalendarVariant<D extends CalendarVariant<D>> extends ChronoEntity<D> implements java.lang.Comparable<D>, Temporal<CalendarVariant<?>>, java.io.Serializable
Represents an immutable calendar variant.
Display and change chronological element values
The calendar variant consists of chronological elements. This base class
delegates the elment and time arithmetic to the associated calendar family respective to
the underlying rules of elements and units. However, any concrete subclass
is required to define the state and reflect it in all get()-methods
and also to specify the serialization behaviour.
Element values can only be changed by creating a new immutable copy
of the original instance. This is done via all with()-methods.
Calendar system
Every calendar variant is a member of a calendar family. That means referring to
a calendar system via a variant name. Hence a limited day arithmetic using the
class CalendarDays is always possible.
Sorting
The sorting algorithm prefers the temporal order then the lexicographical comparison
based on variant names. In case of doubt the documentation of the subclass is leading.
Alternatively, the interface Temporal can be used to enable a pure temporal order.
Implementation notes
equals(). Chronology,
CalendarFamily| Constructor and Description |
|---|
CalendarVariant() |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(D calendarVariant)
Compares two calendar variants preferably by their temporal positions
on the common date axis and then by their variant names.
|
abstract boolean |
equals(java.lang.Object obj)
Compares the whole state of this instance with given object.
|
abstract java.lang.String |
getVariant()
Returns the name of the associated variant of underlying calendar system.
|
abstract int |
hashCode()
Subclasses must redefine this method corresponding to the
behaviour of
equals(). |
boolean |
isAfter(CalendarVariant<?> other)
Queries if this object is after given object on a timeline.
|
boolean |
isBefore(CalendarVariant<?> other)
Queries if this object is before given object on a timeline.
|
boolean |
isSimultaneous(CalendarVariant<?> other)
Queries if this object and given object have the same position
on the time axis.
|
D |
minus(CalendarDays days)
Subtracts given calendar days from this instance.
|
D |
plus(CalendarDays days)
Adds given calendar days to this instance.
|
abstract java.lang.String |
toString()
Provides a complete textual representation of the state of this calendar variant.
|
<T extends Calendrical<?,T>> |
transform(java.lang.Class<T> target)
Converts this calendar date to the given target type based on
the count of days relative to UTC epoch [1972-01-01].
|
<T extends CalendarVariant<T>> |
transform(java.lang.Class<T> target,
java.lang.String variant)
Converts this calendar date to the given target type based on
the count of days relative to UTC epoch [1972-01-01].
|
<T extends CalendarVariant<T>> |
transform(java.lang.Class<T> target,
VariantSource variantSource)
Converts this calendar date to the given target type based on
the count of days relative to UTC epoch [1972-01-01].
|
contains, get, get, getMaximum, getMinimum, getTimezone, hasTimezone, isValid, isValid, isValid, matches, with, with, with, withpublic abstract java.lang.String getVariant()
Returns the name of the associated variant of underlying calendar system.
CalendarFamily.getCalendarSystem(String)public <T extends Calendrical<?,T>> T transform(java.lang.Class<T> target)
Converts this calendar date to the given target type based on the count of days relative to UTC epoch [1972-01-01].
The conversion occurs on the local timeline at noon. This reference time ensures that all date types remain convertible even if a calendar system defines dates not starting at midnight.
T - generic target date typetarget - chronological type this date shall be converted tojava.lang.IllegalArgumentException - if the target class does not
have any chronologyjava.lang.ArithmeticException - in case of numerical overflowpublic <T extends CalendarVariant<T>> T transform(java.lang.Class<T> target, java.lang.String variant)
Converts this calendar date to the given target type based on the count of days relative to UTC epoch [1972-01-01].
The conversion occurs on the local timeline at noon. This reference time ensures that all date types remain convertible even if a calendar system defines dates not starting at midnight.
T - generic target date typetarget - chronological type this date shall be converted tovariant - desired calendar variantChronoException - if given variant is not recognizedjava.lang.IllegalArgumentException - if the target class does not have any chronologyjava.lang.ArithmeticException - in case of numerical overflowpublic <T extends CalendarVariant<T>> T transform(java.lang.Class<T> target, VariantSource variantSource)
Converts this calendar date to the given target type based on the count of days relative to UTC epoch [1972-01-01].
The conversion occurs on the local timeline at noon. This reference time ensures that all date types remain convertible even if a calendar system defines dates not starting at midnight.
T - generic target date typetarget - chronological type this date shall be converted tovariantSource - source of desired calendar variantChronoException - if given variant is not recognizedjava.lang.IllegalArgumentException - if the target class does not have any chronologyjava.lang.ArithmeticException - in case of numerical overflowpublic int compareTo(D calendarVariant)
Compares two calendar variants preferably by their temporal positions on the common date axis and then by their variant names.
Implementation note: In order to make the natural order consistent
with equals() the whole state must be taken into account,
with preference for those attributes which define the temporal
position on the time axis.
compareTo in interface java.lang.Comparable<D extends CalendarVariant<D>>calendarVariant - the object to be compared.equals(Object)public boolean isAfter(CalendarVariant<?> other)
TemporalQueries if this object is after given object on a timeline.
isAfter in interface Temporal<CalendarVariant<?>>other - object this instance is compared totrue if this instance is temporally after
temporal else falsepublic boolean isBefore(CalendarVariant<?> other)
TemporalQueries if this object is before given object on a timeline.
isBefore in interface Temporal<CalendarVariant<?>>other - object this instance is compared totrue if this instance is temporally before
temporal else falsepublic boolean isSimultaneous(CalendarVariant<?> other)
TemporalQueries if this object and given object have the same position on the time axis.
Is equivalent to !isAfter(temporal) && !isBefore(temporal).
This method differs from the Object-method equals()
such that first the comparison type must be a temporal one and second
that only temporal-only state will be considered.
isSimultaneous in interface Temporal<CalendarVariant<?>>other - object this instance is compared totrue if this instance is temporally equal
to temporal else falsepublic D plus(CalendarDays days)
Adds given calendar days to this instance.
days - calendar days to be addedpublic D minus(CalendarDays days)
Subtracts given calendar days from this instance.
days - calendar days to be subtractedpublic abstract boolean equals(java.lang.Object obj)
Compares the whole state of this instance with given object.
Implementations will usually define their state based on the temporal position and the variant name. Exceptions from this rule should be explicitly documented and reasoned.
equals in class java.lang.ObjectcompareTo(CalendarVariant)public abstract int hashCode()
Subclasses must redefine this method corresponding to the
behaviour of equals().
hashCode in class java.lang.Objectpublic abstract java.lang.String toString()
Provides a complete textual representation of the state of this calendar variant.
toString in class java.lang.Object