Module life.expert

Interface Unit

  • All Superinterfaces:
    java.lang.Comparable<Unit>
    All Known Implementing Classes:
    Piece

    public interface Unit
    extends java.lang.Comparable<Unit>
    A unit of values. This interface represents a unit of values such as the Kg, Cm, pins or other. It provides interoperability between different implementations. Values can be distinguished by separate getCode() ()} codes, Implementation specification Implementation of this class
    • are required to implement equals/hashCode considering the concrete implementation type and unit code.
    • are required to be thread-safe
    • are required to be immutable
    • are required to be comparable
    • Method Summary

      Modifier and Type Method Description
      java.lang.String getCode()
      Gets the unique unit code, the effective code depends on the unit.
      Context getContext()
      Returns the PieceContext of a unit.
      int getDefaultFractionDigits()
      Gets the number of fractional digits typically used by this unit.
      int getNumericCode()
      Gets a numeric unit code.
      • Methods inherited from interface java.lang.Comparable

        compareTo
    • Method Detail

      • getCode

        java.lang.String getCode()
        Gets the unique unit code, the effective code depends on the unit. Since each unit is identified by this code, the unit code is required to be defined for every Unit and not null or empty.
        Returns:
        the unit code, never null.
      • getNumericCode

        int getNumericCode()
        Gets a numeric unit code. within the ISO name space, this equals to the ISO numeric code. In other unit name spaces this number may be different, or even undefined (-1). The numeric code is an optional alternative to the standard unit code. If defined, the numeric code is required to be unique.
        Returns:
        the numeric unit code
      • getDefaultFractionDigits

        int getDefaultFractionDigits()
        Gets the number of fractional digits typically used by this unit. Different units have different numbers of fractional digits by default.
        Returns:
        the fractional digits, from 0 to 9 (normally 0, 2 or 3), or 0 for pseudo-units.
      • getContext

        Context getContext()
        Returns the PieceContext of a unit. This context contains additional information about the type and capabilities of a Unit, e.g. its provider and more.
        Returns:
        the unit's context, never null.