Top Description Fields Constructors Methods
tech.units.indriya.unit

public Class UnitDimension

extends Object
implements Dimension, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, javax.measure.Dimension
Imports
javax.measure.Dimension, .Quantity, .Unit, tech.units.indriya.AbstractUnit, java.io.Serializable, java.util.HashMap, .Map, .Objects, java.util.logging.Level, java.util.logging.Logger

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);

Authors
Jean-Marie Dautelle, Werner Keil, Martin Desruisseaux (Geomatys), Andi Huber
Since
2.0
Version
2.1, $Date: 2021-03-13 $

Field Summary

Modifier and TypeField and Description
public static final Dimension
AMOUNT_OF_SUBSTANCE

Holds amount of substance dimension (N).

public static final Dimension
ELECTRIC_CURRENT

Holds electric current dimension (I).

public static final Dimension
LENGTH

Holds length dimension (L).

private static final java.util.logging.Logger
public static final Dimension
LUMINOUS_INTENSITY

Holds luminous intensity dimension (J).

public static final Dimension
MASS

Holds mass dimension (M).

public static final Dimension
NONE

Holds dimensionless.

private final Unit<?>
pseudoUnit

Holds the pseudo unit associated to this dimension.

private static final long
public static final Dimension
TEMPERATURE

Holds temperature dimension (Θ).

public static final Dimension
TIME

Holds time dimension (T).

Constructor Summary

AccessConstructor and Description
private
UnitDimension(char
the associated symbol.
symbol
)

Returns the unit dimension having the specified symbol.

private
UnitDimension(Unit<?>
the pseudo-unit.
pseudoUnit
)

Constructor from pseudo-unit (not visible).

protected
UnitDimension()

Default Constructor (not visible).

Method Summary

Modifier and TypeMethod and Description
public Dimension

Returns:

this / that
divide
(Dimension
the dimension divisor.
that
)

Implements javax.measure.Dimension.divide.

Returns the quotient of this dimension with the one specified.

private UnitDimension

Returns:

this / that
divide
(UnitDimension
the dimension divisor.
that
)

Returns the quotient of this dimension with the one specified.

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public Map<? extends Dimension, Integer>

Returns:

the mapping between the base dimensions and their exponent.
getBaseDimensions
()

Implements javax.measure.Dimension.getBaseDimensions.

Returns the fundamental (base) dimensions and their exponent whose product is this dimension or null if this dimension is a fundamental dimension.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public Dimension

Returns:

this * that
multiply
(Dimension
the dimension multiplicand.
that
)

Implements javax.measure.Dimension.multiply.

Returns the product of this dimension with the one specified.

private UnitDimension

Returns:

this * that
multiply
(UnitDimension
the dimension multiplicand.
that
)

Returns the product of this dimension with the one specified.

public static <Q extends Quantity<Q>> Dimension

Returns:

the dimension for the quantity type or null.
of
(Class<Q>
the quantity type.
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.

public static Dimension

Returns:

the dimension for the given symbol.
parse
(char symbol)

Returns the dimension for the specified symbol.

public UnitDimension

Returns:

the result of raising this dimension to the exponent.
pow
(int
the exponent.
n
)

Implements javax.measure.Dimension.pow.

Returns this dimension raised to an exponent.

public UnitDimension

Returns:

the result of taking the given root of this dimension.
root
(int
the root's order.
n
)

Implements javax.measure.Dimension.root.

Returns the given root of this dimension.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

AMOUNT_OF_SUBSTANCEback to summary
public static final Dimension AMOUNT_OF_SUBSTANCE

Holds amount of substance dimension (N).

Since
1.0
ELECTRIC_CURRENTback to summary
public static final Dimension ELECTRIC_CURRENT

Holds electric current dimension (I).

Since
1.0
LENGTHback to summary
public static final Dimension LENGTH

Holds length dimension (L).

Since
1.0
LOGGERback to summary
private static final java.util.logging.Logger LOGGER
LUMINOUS_INTENSITYback to summary
public static final Dimension LUMINOUS_INTENSITY

Holds luminous intensity dimension (J).

MASSback to summary
public static final Dimension MASS

Holds mass dimension (M).

Since
1.0
NONEback to summary
public static final Dimension NONE

Holds dimensionless.

Since
1.0
pseudoUnitback to summary
private final Unit<?> pseudoUnit

Holds the pseudo unit associated to this dimension.

serialVersionUIDback to summary
private static final long serialVersionUID
TEMPERATUREback to summary
public static final Dimension TEMPERATURE

Holds temperature dimension (Θ).

Since
1.0
TIMEback to summary
public static final Dimension TIME

Holds time dimension (T).

Since
1.0

Constructor Detail

UnitDimensionback to summary
private UnitDimension(char symbol)

Returns the unit dimension having the specified symbol.

Parameters
symbol:char

the associated symbol.

Annotations
@SuppressWarnings:rawtypes
UnitDimensionback to summary
private UnitDimension(Unit<?> pseudoUnit)

Constructor from pseudo-unit (not visible).

Parameters
pseudoUnit:Unit<?>

the pseudo-unit.

UnitDimensionback to summary
protected UnitDimension()

Default Constructor (not visible).

Method Detail

divideback to summary
public Dimension divide(Dimension that)

Implements javax.measure.Dimension.divide.

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.

Parameters
that:Dimension

the dimension divisor.

Returns:Dimension

this / that

Since
1.0
divideback to summary
private UnitDimension divide(UnitDimension that)

Returns the quotient of this dimension with the one specified.

Parameters
that:UnitDimension

the dimension divisor.

Returns:UnitDimension

this / that

Since
1.0
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getBaseDimensionsback to summary
public Map<? extends Dimension, Integer> getBaseDimensions()

Implements javax.measure.Dimension.getBaseDimensions.

Returns the fundamental (base) dimensions and their exponent whose product is this dimension or null if this dimension is a fundamental dimension.

Returns:Map<? extends Dimension, Integer>

the mapping between the base dimensions and their exponent.

Annotations
@SuppressWarnings:rawtypes
Since
1.0
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
multiplyback to summary
public Dimension multiply(Dimension that)

Implements javax.measure.Dimension.multiply.

Returns the product of this dimension with the one specified. If the specified dimension is not a UnitDimension, then that.multiply(this) is returned.

Parameters
that:Dimension

the dimension multiplicand.

Returns:Dimension

this * that

Since
1.0
multiplyback to summary
private UnitDimension multiply(UnitDimension that)

Returns the product of this dimension with the one specified.

Parameters
that:UnitDimension

the dimension multiplicand.

Returns:UnitDimension

this * that

Since
1.0
ofback to summary
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:Class<Q>

the quantity type.

Returns:Dimension

the dimension for the quantity type or null.

Since
1.1
parseback to summary
public static Dimension parse(char symbol)

Returns the dimension for the specified symbol.

Returns:Dimension

the dimension for the given symbol.

Since
1.0.1
powback to summary
public UnitDimension pow(int n)

Implements javax.measure.Dimension.pow.

Returns this dimension raised to an exponent.

Parameters
n:int

the exponent.

Returns:UnitDimension

the result of raising this dimension to the exponent.

Since
1.0
rootback to summary
public UnitDimension root(int n)

Implements javax.measure.Dimension.root.

Returns the given root of this dimension.

Parameters
n:int

the root's order.

Returns:UnitDimension

the result of taking the given root of this dimension.

Exceptions
ArithmeticException:
if n == 0.
Since
1.0
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override