Class AnnotatedUnit<Q extends javax.measure.Quantity<Q>>

  • Type Parameters:
    Q - The type of the quantity measured by this unit.
    All Implemented Interfaces:
    Serializable, Comparable<javax.measure.Unit<Q>>, javax.measure.Unit<Q>, ComparableUnit<Q>, tech.uom.lib.common.function.Nameable, tech.uom.lib.common.function.PrefixOperator<Q>, tech.uom.lib.common.function.SymbolSupplier

    public final class AnnotatedUnit<Q extends javax.measure.Quantity<Q>>
    extends AbstractUnit<Q>

    This class represents an annotated unit.

    Instances of this class are created through the of(Unit, String) method.

    Since:
    1.0
    Version:
    1.5, March 30, 2019
    Author:
    Jean-Marie Dautelle, Werner Keil
    See Also:
    Serialized Form
    • Constructor Detail

      • AnnotatedUnit

        public AnnotatedUnit​(javax.measure.Unit<Q> actualUnit,
                             String annotation)
        Creates an annotated unit equivalent to the specified unit.
        Parameters:
        actualUnit - the unit to be annotated.
        annotation - the annotation.
    • Method Detail

      • getActualUnit

        public javax.measure.Unit<Q> getActualUnit()
        Returns the actual unit of this annotated unit (never an annotated unit itself).
        Returns:
        the actual unit.
      • getAnnotation

        public String getAnnotation()
        Returns the annotation of this annotated unit.
        Returns:
        the annotation.
      • getSymbol

        public String getSymbol()
        Specified by:
        getSymbol in interface tech.uom.lib.common.function.SymbolSupplier
        Specified by:
        getSymbol in interface javax.measure.Unit<Q extends javax.measure.Quantity<Q>>
        Overrides:
        getSymbol in class AbstractUnit<Q extends javax.measure.Quantity<Q>>
      • getBaseUnits

        public Map<? extends javax.measure.Unit<?>,​Integer> getBaseUnits()
        Specified by:
        getBaseUnits in interface javax.measure.Unit<Q extends javax.measure.Quantity<Q>>
        Specified by:
        getBaseUnits in class AbstractUnit<Q extends javax.measure.Quantity<Q>>
      • toSystemUnit

        public javax.measure.Unit<Q> toSystemUnit()
        Description copied from class: AbstractUnit
        Returns the unscaled SI unit from which this unit is derived. The SI unit can be be used to identify a quantity given the unit. For example: static boolean isAngularVelocity(AbstractUnit unit) { return unit.toSystemUnit().equals(RADIAN.divide(SECOND)); } assert(REVOLUTION.divide(MINUTE).isAngularVelocity()); // Returns true.
        Specified by:
        toSystemUnit in class AbstractUnit<Q extends javax.measure.Quantity<Q>>
        Returns:
        the unscaled metric unit from which this unit is derived.
      • getDimension

        public javax.measure.Dimension getDimension()
        Specified by:
        getDimension in interface javax.measure.Unit<Q extends javax.measure.Quantity<Q>>
        Specified by:
        getDimension in class AbstractUnit<Q extends javax.measure.Quantity<Q>>
      • getSystemConverter

        public javax.measure.UnitConverter getSystemConverter()
        Description copied from interface: ComparableUnit
        Returns the converter from this unit to its unscaled System Unit unit.
        Returns:
        getConverterTo(this.toSystemUnit())
        See Also:
        #toSystemUnit
      • of

        public static <Q extends javax.measure.Quantity<Q>> AnnotatedUnit<Q> of​(javax.measure.Unit<Q> actualUnit,
                                                                                String annotation)
        Creates an annotated unit equivalent to the specified unit.
        Parameters:
        actualUnit - the unit to be annotated.
        annotation - the annotation.
        Returns:
        the annotated unit.