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 TypeMethodDescriptionint
compare(ChronoDisplay o1, ChronoDisplay o2)
Compares the values of this element based on their natural order.boolean
Based on equality of element names AND element classes.char
There is no format symbol by default.int
hashCode()
Based on the element name.boolean
Chronological elements are strict by default.boolean
isLocal()
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, isTimeElement
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Method Details
-
name
Description copied from interface:ChronoElement
Returns 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:
name
in 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:
compare
in interfaceChronoElement<V extends Comparable<V>>
- Specified by:
compare
in 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
FormattableElement
for documentation support.- Specified by:
getSymbol
in 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:
isLenient
in 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:
equals
in interfaceComparator<V extends Comparable<V>>
- Overrides:
equals
in classObject
- Returns:
true
if 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.
-