Class UnitDimension

  • All Implemented Interfaces:
    Serializable, Dimension

    public class UnitDimension
    extends Object
    implements Dimension, Serializable

    This class represents a dimension of a unit of measurement.

    The dimension associated to any given quantity are given by the published Dimension instances. For convenience, a static method UnitDimension.of(Class) aggregating the results of all Dimension instances is provided.

    Dimension speedDimension = UnitDimension.of(Speed.class);

    Since:
    2.0
    Version:
    2.1, $Date: 2021-03-13 $
    Author:
    Jean-Marie Dautelle, Werner Keil, Martin Desruisseaux (Geomatys), Andi Huber
    See Also:
    Serialized Form
    • Constructor Detail

      • UnitDimension

        protected UnitDimension()
        Default Constructor (not visible).
    • Method Detail

      • of

        public static <Q extends Quantity<Q>> Dimension of​(Class<Q> quantityType)
        Returns the dimension for the specified quantity type by aggregating the results from the default SystemOfUnits or null if the specified quantity is unknown.
        Parameters:
        quantityType - the quantity type.
        Returns:
        the dimension for the quantity type or null.
        Since:
        1.1
      • parse

        public static Dimension parse​(char symbol)
        Returns the dimension for the specified symbol.
        Parameters:
        sambol - the quantity symbol.
        Returns:
        the dimension for the given symbol.
        Since:
        1.0.1
      • multiply

        public Dimension multiply​(Dimension that)
        Returns the product of this dimension with the one specified. If the specified dimension is not a UnitDimension, then that.multiply(this) is returned.
        Specified by:
        multiply in interface Dimension
        Parameters:
        that - the dimension multiplicand.
        Returns:
        this * that
        Since:
        1.0
      • divide

        public Dimension divide​(Dimension that)
        Returns the quotient of this dimension with the one specified. If the specified dimension is not a UnitDimension, then that.divide(this).pow(-1) is returned.
        Specified by:
        divide in interface Dimension
        Parameters:
        that - the dimension divisor.
        Returns:
        this / that
        Since:
        1.0
      • pow

        public UnitDimension pow​(int n)
        Returns this dimension raised to an exponent.
        Specified by:
        pow in interface Dimension
        Parameters:
        n - the exponent.
        Returns:
        the result of raising this dimension to the exponent.
        Since:
        1.0
      • root

        public UnitDimension root​(int n)
        Returns the given root of this dimension.
        Specified by:
        root in interface Dimension
        Parameters:
        n - the root's order.
        Returns:
        the result of taking the given root of this dimension.
        Throws:
        ArithmeticException - if n == 0.
        Since:
        1.0
      • getBaseDimensions

        public Map<? extends Dimension,​IntegergetBaseDimensions()
        Returns the fundamental (base) dimensions and their exponent whose product is this dimension or null if this dimension is a fundamental dimension.
        Specified by:
        getBaseDimensions in interface Dimension
        Returns:
        the mapping between the base dimensions and their exponent.
        Since:
        1.0