The base class for our UnitConverter implementations.
| Modifier and Type | Class and Description |
|---|---|
| private static class | AbstractConverter.
This class represents the identity converter (singleton). |
| public static class | AbstractConverter.
This class represents converters made up of two or more separate converters
(in matrix notation |
| Modifier and Type | Field and Description |
|---|---|
| protected List | conversionSteps
memorization for getConversionSteps |
| public static final AbstractConverter | IDENTITY
Default identity converter implementing AbstractConverter. |
| private static final long | |
| public static ConverterCompositionHandler | UNIT_COMPOSITION_HANDLER
Allows for plug in of a custom UnitCompositionHandler. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected abstract boolean | Returns: whether or not a composition with giventhat is possible, such
that no additional conversion steps are required, with respect to the steps already
in place by this converterNon-API
Guard for |
| public final UnitConverter | concatenate(UnitConverter
the other converter to concatenate with this converter. converter)Implements javax. Concatenates this converter with another converter. |
| public final double | convert(double
the numeric value to convert. value)Implements javax. Converts a |
| public final Number | convert(Number
the value)Number value to convert.Implements javax. Converts a |
| protected abstract Number | |
| public abstract boolean | equals(Object
the reference object with which to compare. cvtr)Overrides java. Indicates whether some other object is "equal to" this one. |
| public final List | getConversionSteps()
Implements javax.
Returns the steps of fundamental converters making up this converter or |
| public abstract int | |
| public final AbstractConverter | |
| protected abstract AbstractConverter | inverseWhenNotIdentity()
Non-API Returns an AbstractConverter that represents the inverse transformation of this converter, for cases where the transformation is not the identity transformation. |
| public Optional | Returns: optionally the linear factor of this transformation's first derivative, based on whether this transformation allows for RELATIVE scaled QuantitiesEven though transformations may be composed of addition and multiplication, the first derivative might just be a linear function. |
| protected AbstractConverter | Returns: a new AbstractConverter that adds no additional conversion steps, with respect to the steps already in place by this converterNon-API
Guarded by |
| public final String | |
| protected abstract String | transformationLiteral()
Non-API Returns a String describing the transformation that is represented by this converter. |
| conversionSteps | back to summary |
|---|---|
| protected List<? extends UnitConverter> conversionSteps memorization for getConversionSteps | |
| IDENTITY | back to summary |
|---|---|
| public static final AbstractConverter IDENTITY Default identity converter implementing AbstractConverter. Note Checking whether a UnitConverter is an identity operator should be done with
| |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| UNIT_COMPOSITION_HANDLER | back to summary |
|---|---|
| public static ConverterCompositionHandler UNIT_COMPOSITION_HANDLER Allows for plug in of a custom UnitCompositionHandler. | |
| AbstractConverter | back to summary |
|---|---|
| protected AbstractConverter() DefaultQuantityFactory constructor. | |
| canReduceWith | back to summary |
|---|---|
| protected abstract boolean canReduceWith(AbstractConverter that) Non-API
Guard for
| |
| concatenate | back to summary |
|---|---|
| public final UnitConverter concatenate(UnitConverter converter) Implements javax. Doc from javax. 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).
| |
| convert | back to summary |
|---|---|
| public final double convert(double value) Implements javax. Doc from javax. Converts a
| |
| convert | back to summary |
|---|---|
| public final Number convert(Number value) Implements javax. Doc from javax. Converts a
| |
| convertWhenNotIdentity | back to summary |
|---|---|
| protected abstract Number convertWhenNotIdentity(Number value) Non-API
| |
| equals | back to summary |
|---|---|
| public abstract boolean equals(Object cvtr) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
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. | |
| getConversionSteps | back to summary |
|---|---|
| public final List Implements javax. Doc from javax.
Returns the steps of fundamental converters making up this converter or
For example,
| |
| hashCode | back to summary |
|---|---|
| public abstract int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| inverse | back to summary |
|---|---|
| public final AbstractConverter inverse() Implements javax. Doc from javax. Returns the inverse of this converter. If
| |
| inverseWhenNotIdentity | back to summary |
|---|---|
| protected abstract AbstractConverter inverseWhenNotIdentity() Non-API Returns an AbstractConverter that represents the inverse transformation of this converter, for cases where the transformation is not the identity transformation. | |
| linearFactor | back to summary |
|---|---|
| public Optional Even though transformations may be composed of addition and multiplication, the first derivative might just be a linear function. This is strictly required for Quantities that are expressed with RELATIVE scope. Eg. Δ2°C or Δ2°F. Otherwise such deltas cannot be converted to ABSOLUTE scope without additional information. | |
| reduce | back to summary |
|---|---|
| protected AbstractConverter reduce(AbstractConverter that) Non-API
Guarded by
| |
| toString | back to summary |
|---|---|
| public final String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| transformationLiteral | back to summary |
|---|---|
| protected abstract String transformationLiteral() Non-API
Returns a String describing the transformation that is represented by this converter.
Contributes to converter's | |
| Modifier and Type | Field and Description |
|---|---|
| private static final Optional | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | canReduceWith(AbstractConverter that)
Implements abstract tech. Non-API
Guard for |
| public int | compareTo(UnitConverter
the object to be compared. o)Implements java. Compares this object with the specified object for order. |
| protected Number | convertWhenNotIdentity(Number value)
Implements abstract tech. Non-API |
| public boolean | equals(Object
the reference object with which to compare. cvtr)Implements abstract tech. Indicates whether some other object is "equal to" this one. |
| public int | hashCode()
Implements abstract tech. Returns a hash code value for this object. |
| protected AbstractConverter | inverseWhenNotIdentity()
Implements abstract tech. Non-API Returns an AbstractConverter that represents the inverse transformation of this converter, for cases where the transformation is not the identity transformation. |
| public boolean | isIdentity()
Implements javax. Indicates if this converter is an identity converter. |
| public boolean | isLinear()
Implements javax. 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. |
| public Optional | linearFactor()
Overrides tech. Even though transformations may be composed of addition and multiplication, the first derivative might just be a linear function. |
| protected AbstractConverter | reduce(AbstractConverter that)
Overrides tech. Non-API
Guarded by |
| protected String | transformationLiteral()
Implements abstract tech. Non-API Returns a String describing the transformation that is represented by this converter. |
| private IllegalStateException |
| ONE | back to summary |
|---|---|
| private static final Optional<Number> ONE | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides tech. | |
| Identity | back to summary |
|---|---|
| private Identity() | |
| canReduceWith | back to summary |
|---|---|
| protected boolean canReduceWith(AbstractConverter that) Implements abstract tech. Doc from tech. Non-API
Guard for
| |
| compareTo | back to summary |
|---|---|
| public int compareTo(UnitConverter o) Implements java. Doc from java. Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. The implementor must ensure The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| convertWhenNotIdentity | back to summary |
|---|---|
| protected Number convertWhenNotIdentity(Number value) Implements abstract tech. Doc from tech. Non-API | |
| equals | back to summary |
|---|---|
| public boolean equals(Object cvtr) Implements abstract tech. Doc from java. Indicates whether some other object is "equal to" this one.
The
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. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Implements abstract tech. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| inverseWhenNotIdentity | back to summary |
|---|---|
| protected AbstractConverter inverseWhenNotIdentity() Implements abstract tech. Doc from tech. Non-API Returns an AbstractConverter that represents the inverse transformation of this converter, for cases where the transformation is not the identity transformation.
| |
| isIdentity | back to summary |
|---|---|
| public boolean isIdentity() Implements javax. Doc from javax. Indicates if this converter is an identity converter. The identity converter returns its input argument ( Note Identity converters are also always 'linear', see
| |
| isLinear | back to summary |
|---|---|
| public boolean isLinear() Implements javax. Doc from javax. 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:
Given a second 'linear' converter 'B', commutativity of composition follows by above definition:
A(B(u)) == B(A(u)), meaning
for 'A' and 'B' the order of their composition does not matter. Expressed as Java code:
UnitConverter#concatenate(UnitConverter).
| |
| linearFactor | back to summary |
|---|---|
| public Optional Overrides tech. Doc from tech. Even though transformations may be composed of addition and multiplication, the first derivative might just be a linear function. This is strictly required for Quantities that are expressed with RELATIVE scope. Eg. Δ2°C or Δ2°F. Otherwise such deltas cannot be converted to ABSOLUTE scope without additional information. | |
| reduce | back to summary |
|---|---|
| protected AbstractConverter reduce(AbstractConverter that) Overrides tech. Doc from tech. Non-API
Guarded by
| |
| transformationLiteral | back to summary |
|---|---|
| protected String transformationLiteral() Implements abstract tech. Doc from tech. Non-API
Returns a String describing the transformation that is represented by this converter.
Contributes to converter's
| |
| unreachable | back to summary |
|---|---|
| private IllegalStateException unreachable() | |
[pair] = [left] x [right]).
| Modifier and Type | Field and Description |
|---|---|
| private final UnitConverter | left
Holds the first converter. |
| private final UnitConverter | right
Holds the second converter. |
| private static final long | |
| private static final Comparator |
| Access | Constructor and Description |
|---|---|
| public | Pair(UnitConverter
the left converter, not left, UnitConverter null.the right converter. right)Creates a pair converter resulting from the combined transformation of the specified converters. |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | canReduceWith(AbstractConverter that)
Implements abstract tech. Non-API
Guard for |
| public int | compareTo(UnitConverter
the object to be compared. obj)Implements java. Compares this object with the specified object for order. |
| protected Number | convertWhenNotIdentity(Number value)
Implements abstract tech. Non-API |
| protected List | |
| public boolean | equals(Object
the reference object with which to compare. obj)Implements abstract tech. Indicates whether some other object is "equal to" this one. |
| public UnitConverter | |
| public UnitConverter | |
| public int | hashCode()
Implements abstract tech. Returns a hash code value for this object. |
| public AbstractConverter. | inverseWhenNotIdentity()
Implements abstract tech. Non-API Returns an AbstractConverter that represents the inverse transformation of this converter, for cases where the transformation is not the identity transformation. |
| public boolean | isIdentity()
Implements javax. Indicates if this converter is an identity converter. |
| public boolean | isLinear()
Implements javax. 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. |
| public Optional | linearFactor()
Overrides tech. Even though transformations may be composed of addition and multiplication, the first derivative might just be a linear function. |
| private IllegalArgumentException | |
| protected String | transformationLiteral()
Implements abstract tech. Non-API Returns a String describing the transformation that is represented by this converter. |
| left | back to summary |
|---|---|
| private final UnitConverter left Holds the first converter. | |
| right | back to summary |
|---|---|
| private final UnitConverter right Holds the second converter. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides tech. | |
| unitComparator | back to summary |
|---|---|
private static final Comparator<T> unitComparator
| |
| Pair | back to summary |
|---|---|
| public Pair(UnitConverter left, UnitConverter right) Creates a pair converter resulting from the combined transformation of the specified converters.
| |
| canReduceWith | back to summary |
|---|---|
| protected boolean canReduceWith(AbstractConverter that) Implements abstract tech. Doc from tech. Non-API
Guard for
| |
| compareTo | back to summary |
|---|---|
| public int compareTo(UnitConverter obj) Implements java. Doc from java. Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. The implementor must ensure The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| convertWhenNotIdentity | back to summary |
|---|---|
| protected Number convertWhenNotIdentity(Number value) Implements abstract tech. Doc from tech. Non-API | |
| createConversionSteps | back to summary |
|---|---|
| protected List | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Implements abstract tech. Doc from java. Indicates whether some other object is "equal to" this one.
The
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. | |
| getLeft | back to summary |
|---|---|
| public UnitConverter getLeft() | |
| getRight | back to summary |
|---|---|
| public UnitConverter getRight() | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Implements abstract tech. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| inverseWhenNotIdentity | back to summary |
|---|---|
| public AbstractConverter. Implements abstract tech. Doc from tech. Non-API Returns an AbstractConverter that represents the inverse transformation of this converter, for cases where the transformation is not the identity transformation.
| |
| isIdentity | back to summary |
|---|---|
| public boolean isIdentity() Implements javax. Doc from javax. Indicates if this converter is an identity converter. The identity converter returns its input argument ( Note Identity converters are also always 'linear', see
| |
| isLinear | back to summary |
|---|---|
| public boolean isLinear() Implements javax. Doc from javax. 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:
Given a second 'linear' converter 'B', commutativity of composition follows by above definition:
A(B(u)) == B(A(u)), meaning
for 'A' and 'B' the order of their composition does not matter. Expressed as Java code:
UnitConverter#concatenate(UnitConverter).
| |
| linearFactor | back to summary |
|---|---|
| public Optional Overrides tech. Doc from tech. Even though transformations may be composed of addition and multiplication, the first derivative might just be a linear function. This is strictly required for Quantities that are expressed with RELATIVE scope. Eg. Δ2°C or Δ2°F. Otherwise such deltas cannot be converted to ABSOLUTE scope without additional information. | |
| requiresAbstractConverter | back to summary |
|---|---|
| private IllegalArgumentException requiresAbstractConverter() | |
| transformationLiteral | back to summary |
|---|---|
| protected String transformationLiteral() Implements abstract tech. Doc from tech. Non-API
Returns a String describing the transformation that is represented by this converter.
Contributes to converter's
| |