Class AbstractSystemOfUnits

  • All Implemented Interfaces:
    javax.measure.spi.SystemOfUnits, tech.uom.lib.common.function.Nameable
    Direct Known Subclasses:
    Units

    public abstract class AbstractSystemOfUnits
    extends Object
    implements javax.measure.spi.SystemOfUnits, tech.uom.lib.common.function.Nameable

    An abstract base class for unit systems.

    Since:
    1.0
    Version:
    2.0, Feb 18, 2020
    Author:
    Werner Keil
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static double E
      The natural logarithm.
      protected static Logger logger  
      protected Map<Class<? extends javax.measure.Quantity>,​javax.measure.Unit> quantityToUnit
      Holds the mapping quantity to unit.
      protected Set<javax.measure.Unit<?>> units
      Holds the units.
    • Field Detail

      • units

        protected final Set<javax.measure.Unit<?>> units
        Holds the units.
      • quantityToUnit

        protected final Map<Class<? extends javax.measure.Quantity>,​javax.measure.Unit> quantityToUnit
        Holds the mapping quantity to unit.
    • Method Detail

      • getName

        public abstract String getName()
        Specified by:
        getName in interface tech.uom.lib.common.function.Nameable
        Specified by:
        getName in interface javax.measure.spi.SystemOfUnits
      • getUnits

        public Set<javax.measure.Unit<?>> getUnits()
        Specified by:
        getUnits in interface javax.measure.spi.SystemOfUnits
      • getUnits

        public Set<? extends javax.measure.Unit<?>> getUnits​(javax.measure.Dimension dimension)
        Specified by:
        getUnits in interface javax.measure.spi.SystemOfUnits
      • getUnit

        public <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> getUnit​(Class<Q> quantityType)
        Specified by:
        getUnit in interface javax.measure.spi.SystemOfUnits
      • getUnit

        public javax.measure.Unit<?> getUnit​(String string)
        Specified by:
        getUnit in interface javax.measure.spi.SystemOfUnits
      • getUnit

        public javax.measure.Unit<?> getUnit​(String string,
                                             UnitStyle style,
                                             boolean ignoreCase)

        Returns a unit with the given string representation in a particular style or null if none is found in this unit system and requested style.

        NOTE: Use ignoreCase carefully, as it will find the FIRST unit for a particular string, e.g. the symbol of SECOND and SIEMENS would be the same without case, but the UPPERCASE letter sorted first.

        Parameters:
        string - the string representation of a unit, not null.
        style - the style of unit representation.
        ignoreCase - ignore the case or not?
        Returns:
        the unit with the given string representation.
        Since:
        2.0
      • getUnit

        public javax.measure.Unit<?> getUnit​(String string,
                                             UnitStyle style)
        Returns a unit with the given string representation in a particular style or null if none is found in this unit system and requested style.
        Parameters:
        string - the string representation of a unit, not null.
        style - the style of unit representation.
        Returns:
        the unit with the given string representation.
        Since:
        2.0