Top Description Methods
javax.measure

public Interface UnitConverter

Imports
java.util.List

A converter of numeric values between different units.

Instances of this class are usually obtained through the Unit#getConverterTo(Unit) method.

Authors
Jean-Marie Dautelle, Werner Keil, Martin Desruisseaux, Thodoris Bais, Andi Huber
Since
1.0
Version
1.4, May 12, 2019
See Also
Unit, Wikipedia: Conversion of units

Method Summary

Modifier and TypeMethod and Description
public UnitConverter

Returns:

the concatenation of this converter with the other converter.
concatenate
(UnitConverter
the other converter to concatenate with this converter.
converter
)

Concatenates this converter with another converter.

public Number

Returns:

the Number value after conversion.
convert
(Number
the Number value to convert.
value
)

Converts a Number value.

public double

Returns:

the double value after conversion.
convert
(double
the numeric value to convert.
value
)

Converts a double value.

public List<? extends UnitConverter>

Returns:

the list of fundamental converters which concatenated make up this converter.
getConversionSteps
()

Returns the steps of fundamental converters making up this converter or this if the converter is a fundamental converter.

public UnitConverter

Returns:

the inverse of this converter.
inverse
()

Returns the inverse of this converter.

public boolean

Returns:

true if this converter is an identity converter.
isIdentity
()

Indicates if this converter is an identity converter.

public boolean

Returns:

true if this converter represents a linear transformation; false otherwise.
isLinear
()

Indicates whether this converter represents a (one-dimensional) linear transformation, that is a linear map (wikipedia) from a one-dimensional vector space (a scalar) to a one-dimensional vector space.

Method Detail

concatenateback to summary
public UnitConverter concatenate(UnitConverter converter)

Concatenates this converter with another converter. The resulting converter is equivalent to first converting by the specified converter (right converter), and then converting by this converter (left converter).

Parameters
converter:UnitConverter

the other converter to concatenate with this converter.

Returns:UnitConverter

the concatenation of this converter with the other converter.

convertback to summary
public Number convert(Number value)

Converts a Number value.

Parameters
value:Number

the Number value to convert.

Returns:Number

the Number value after conversion.

convertback to summary
public double convert(double value)

Converts a double value.

Parameters
value:double

the numeric value to convert.

Returns:double

the double value after conversion.

getConversionStepsback to summary
public List<? extends UnitConverter> getConversionSteps()

Returns the steps of fundamental converters making up this converter or this if the converter is a fundamental converter.

For example, converter1.getConversionSteps() returns converter1 while converter1.concatenate(converter2).getConversionSteps() returns converter1, converter2.

Returns:List<? extends UnitConverter>

the list of fundamental converters which concatenated make up this converter.

inverseback to summary
public UnitConverter inverse()

Returns the inverse of this converter. If x is a valid value, then x == inverse().convert(convert(x)) to within the accuracy of computer arithmetic.

Returns:UnitConverter

the inverse of this converter.

isIdentityback to summary
public boolean isIdentity()

Indicates if this converter is an identity converter. The identity converter returns its input argument (convert(x) == x).

Note

Identity converters are also always 'linear', see UnitConverter#isLinear().

Returns:boolean

true if this converter is an identity converter.

isLinearback to summary
public boolean isLinear()

Indicates whether this converter represents a (one-dimensional) linear transformation, that is a linear map (wikipedia) from a one-dimensional vector space (a scalar) to a one-dimensional vector space. Typically from 'R' to 'R', with 'R' the real numbers.

Given such a 'linear' converter 'A', let 'u', 'v' and 'r' be arbitrary numbers, then the following must hold by definition:

  • A(u + v) == A(u) + A(v)
  • A(r * u) == r * A(u)

Given a second 'linear' converter 'B', commutativity of composition follows by above definition:

  • (A o B) (u) == (B o A) (u)
In other words, two 'linear' converters do have the property that A(B(u)) == B(A(u)), meaning for 'A' and 'B' the order of their composition does not matter. Expressed as Java code:

A.concatenate(B).convert(u) == B.concatenate(A).convert(u)

Note: For composing UnitConverters see also UnitConverter#concatenate(UnitConverter).
Returns:boolean

true if this converter represents a linear transformation; false otherwise.