Package tech.units.indriya.unit
Class UnitDimension
- java.lang.Object
-
- tech.units.indriya.unit.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
Dimensioninstances. For convenience, a static methodUnitDimension.of(Class)aggregating the results of allDimensioninstances 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
-
-
Field Summary
Fields Modifier and Type Field Description static DimensionAMOUNT_OF_SUBSTANCEHolds amount of substance dimension (N).static DimensionELECTRIC_CURRENTHolds electric current dimension (I).static DimensionLENGTHHolds length dimension (L).static DimensionLUMINOUS_INTENSITYHolds luminous intensity dimension (J).static DimensionMASSHolds mass dimension (M).static DimensionNONEHolds dimensionless.static DimensionTEMPERATUREHolds temperature dimension (Θ).static DimensionTIMEHolds time dimension (T).
-
Constructor Summary
Constructors Modifier Constructor Description protectedUnitDimension()Default Constructor (not visible).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Dimensiondivide(Dimension that)Returns the quotient of this dimension with the one specified.booleanequals(Object obj)Map<? extends Dimension,Integer>getBaseDimensions()Returns the fundamental (base) dimensions and their exponent whose product is this dimension ornullif this dimension is a fundamental dimension.inthashCode()Dimensionmultiply(Dimension that)Returns the product of this dimension with the one specified.static <Q extends Quantity<Q>>
Dimensionof(Class<Q> quantityType)Returns the dimension for the specified quantity type by aggregating the results from the defaultSystemOfUnitsornullif the specified quantity is unknown.static Dimensionparse(char symbol)Returns the dimension for the specified symbol.UnitDimensionpow(int n)Returns this dimension raised to an exponent.UnitDimensionroot(int n)Returns the given root of this dimension.StringtoString()
-
-
-
Field Detail
-
ELECTRIC_CURRENT
public static final Dimension ELECTRIC_CURRENT
Holds electric current dimension (I).- Since:
- 1.0
-
TEMPERATURE
public static final Dimension TEMPERATURE
Holds temperature dimension (Θ).- Since:
- 1.0
-
AMOUNT_OF_SUBSTANCE
public static final Dimension AMOUNT_OF_SUBSTANCE
Holds amount of substance dimension (N).- Since:
- 1.0
-
LUMINOUS_INTENSITY
public static final Dimension LUMINOUS_INTENSITY
Holds luminous intensity dimension (J).
-
-
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 defaultSystemOfUnitsornullif 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 aUnitDimension, thenthat.multiply(this)is returned.
-
divide
public Dimension divide(Dimension that)
Returns the quotient of this dimension with the one specified. If the specified dimension is not aUnitDimension, thenthat.divide(this).pow(-1)is returned.
-
pow
public UnitDimension pow(int n)
Returns this dimension raised to an exponent.
-
root
public UnitDimension root(int n)
Returns the given root of this dimension.- Specified by:
rootin interfaceDimension- Parameters:
n- the root's order.- Returns:
- the result of taking the given root of this dimension.
- Throws:
ArithmeticException- ifn == 0.- Since:
- 1.0
-
getBaseDimensions
public Map<? extends Dimension,Integer> getBaseDimensions()
Returns the fundamental (base) dimensions and their exponent whose product is this dimension ornullif this dimension is a fundamental dimension.- Specified by:
getBaseDimensionsin interfaceDimension- Returns:
- the mapping between the base dimensions and their exponent.
- Since:
- 1.0
-
-