Class BasicElement<V extends Comparable<V>>

java.lang.Object
net.time4j.engine.BasicElement<V>
Type Parameters:
V - generic type of element values
All Implemented Interfaces:
Serializable, Comparator<ChronoDisplay>, ChronoElement<V>
Direct Known Subclasses:
DisplayElement

public abstract class BasicElement<V extends Comparable<V>> extends Object implements ChronoElement<V>, Serializable

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 Details

    • name

      public final String 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 interface ChronoElement<V extends Comparable<V>>
      Returns:
      name of element, unique within a chronology
    • compare

      public int compare(ChronoDisplay o1, ChronoDisplay o2)

      Compares the values of this element based on their natural order.

      Specified by:
      compare in interface ChronoElement<V extends Comparable<V>>
      Specified by:
      compare in interface Comparator<V extends Comparable<V>>
      Parameters:
      o1 - the first object to be compared
      o2 - 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 interface ChronoElement<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 interface ChronoElement<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

      public final boolean equals(Object obj)

      Based on equality of element names AND element classes.

      Specified by:
      equals in interface Comparator<V extends Comparable<V>>
      Overrides:
      equals in class Object
      Returns:
      true if this instance and the argument are of same class and have same names else false
    • hashCode

      public final int hashCode()

      Based on the element name.

      Overrides:
      hashCode in class Object
      Returns:
      int
    • toString

      public String toString()

      Serves mainly for debugging support.

      For display purpose the method name() is to be preferred.

      Overrides:
      toString in class Object
      Returns:
      String