Class BasicElement<V extends Comparable<V>>
- Type Parameters:
V- generic type of element values
- All Implemented Interfaces:
Serializable,Comparator<ChronoDisplay>,ChronoElement<V>
- Direct Known Subclasses:
DisplayElement
Abstract base implementation of a chronological element which has a name and can also define an (unregistered) element rule.
- Author:
- Meno Hochschild
- See Also:
- Serialized Form
-
Method Summary
Modifier and TypeMethodDescriptionintcompare(ChronoDisplay o1, ChronoDisplay o2)Compares the values of this element based on their natural order.booleanBased on equality of element names AND element classes.charThere is no format symbol by default.inthashCode()Based on the element name.booleanChronological elements are strict by default.booleanisLocal()Elements are local by default and can therefore not be used in a global context.name()Returns the name which is unique within the context of a given chronology.toString()Serves mainly for debugging support.Methods inherited from interface net.time4j.engine.ChronoElement
getDefaultMaximum, getDefaultMinimum, getDisplayName, getType, isDateElement, isTimeElementMethods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Method Details
-
name
Description copied from interface:ChronoElementReturns the name which is unique within the context of a given chronology.
The name can also serve as resource key together with the name of a chronology for a localized description.
- Specified by:
namein interfaceChronoElement<V extends Comparable<V>>- Returns:
- name of element, unique within a chronology
-
compare
Compares the values of this element based on their natural order.
- Specified by:
comparein interfaceChronoElement<V extends Comparable<V>>- Specified by:
comparein interfaceComparator<V extends Comparable<V>>- Parameters:
o1- the first object to be comparedo2- the second object to be compared- Returns:
- a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second
- Throws:
ChronoException- if this element is not registered in any entity and/or if no element rule exists to extract the element value- Since:
- 3.5/4.3
-
getSymbol
public char getSymbol()There is no format symbol by default.
In order to define a format symbol subclasses must override this methode. In that case such an element instance should be annotated with the annotation
FormattableElementfor documentation support.- Specified by:
getSymbolin interfaceChronoElement<V extends Comparable<V>>- Returns:
- ASCII-0 (placeholder for an undefined format symbol)
- See Also:
FormattableElement
-
isLenient
public boolean isLenient()Chronological elements are strict by default.
- Specified by:
isLenientin interfaceChronoElement<V extends Comparable<V>>- Returns:
false- See Also:
ElementRule.withValue(T, V, boolean)
-
isLocal
public boolean isLocal()Elements are local by default and can therefore not be used in a global context.
- Returns:
true- Since:
- 2.0
- See Also:
getVeto(Chronology)
-
equals
Based on equality of element names AND element classes.
- Specified by:
equalsin interfaceComparator<V extends Comparable<V>>- Overrides:
equalsin classObject- Returns:
trueif this instance and the argument are of same class and have same names elsefalse
-
hashCode
public final int hashCode()Based on the element name.
-
toString
Serves mainly for debugging support.
For display purpose the method
name()is to be preferred.
-