Package tech.units.indriya
Class AbstractConverter
java.lang.Object
tech.units.indriya.AbstractConverter
- All Implemented Interfaces:
Serializable
,Comparable<javax.measure.UnitConverter>
,javax.measure.UnitConverter
- Direct Known Subclasses:
AbstractConverter.Identity
,AbstractConverter.Pair
,AddConverter
,ExpConverter
,LogConverter
,MultiplyConverter
,PowersOfIntConverter
,PowersOfPiConverter
,RationalConverter
public abstract class AbstractConverter
extends Object
implements javax.measure.UnitConverter, Serializable, Comparable<javax.measure.UnitConverter>
The base class for our UnitConverter
implementations.
- Since:
- 1.0
- Version:
- 1.6, April 26, 2018
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
This class represents the identity converter (singleton).static final class
This class represents converters made up of two or more separate converters (in matrix notation[pair] = [left] x [right]
). -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<? extends javax.measure.UnitConverter>
memoization for getConversionStepsstatic final AbstractConverter
Holds identity converter.private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal javax.measure.UnitConverter
concatenate
(javax.measure.UnitConverter converter) final double
convert
(double value) final Number
protected abstract double
convertWhenNotIdentity
(double value) Non-APIprotected abstract BigDecimal
convertWhenNotIdentity
(BigDecimal value, MathContext ctx) Non-APIprotected Number
convertWhenNotIdentity
(BigInteger value, MathContext ctx) Non-APIabstract boolean
final List<? extends javax.measure.UnitConverter>
abstract int
hashCode()
final AbstractConverter
inverse()
protected abstract AbstractConverter
Non-APIprotected abstract boolean
Non-API Guard forsimpleCompose(AbstractConverter)
static javax.measure.UnitConverter
Creates a converter with the specified Prefix.protected AbstractConverter
Non-API Guarded byisSimpleCompositionWith(AbstractConverter)
final String
toString()
protected abstract String
Non-APIMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface javax.measure.UnitConverter
isIdentity, isLinear
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
IDENTITY
Holds identity converter. -
conversionSteps
memoization for getConversionSteps
-
-
Constructor Details
-
AbstractConverter
protected AbstractConverter()DefaultQuantityFactory constructor.
-
-
Method Details
-
of
Creates a converter with the specified Prefix.- Parameters:
prefix
- the prefix for the factor.
-
equals
-
hashCode
public abstract int hashCode() -
transformationLiteral
Non-APIReturns a String describing the transformation that is represented by this converter. Contributes to converter's
toString
method. If null or emptytoString
output becomes simplified.- Returns:
-
toString
-
inverseWhenNotIdentity
Non-APIReturns an AbstractConverter that represents the inverse transformation of this converter, for cases where the transformation is not the identity transformation.
- Returns:
-
inverse
- Specified by:
inverse
in interfacejavax.measure.UnitConverter
-
isSimpleCompositionWith
Non-API Guard forsimpleCompose(AbstractConverter)
- Parameters:
that
-- Returns:
- whether or not a 'simple' composition of transformations is possible
-
simpleCompose
Non-API Guarded byisSimpleCompositionWith(AbstractConverter)
- Parameters:
that
-- Returns:
- a new AbstractConverter that adds no additional conversion step
-
concatenate
public final javax.measure.UnitConverter concatenate(javax.measure.UnitConverter converter) - Specified by:
concatenate
in interfacejavax.measure.UnitConverter
-
getConversionSteps
- Specified by:
getConversionSteps
in interfacejavax.measure.UnitConverter
-
convertWhenNotIdentity
protected abstract double convertWhenNotIdentity(double value) Non-API- Parameters:
value
-- Returns:
- transformed value
-
convertWhenNotIdentity
Non-API- Parameters:
value
-ctx
-- Returns:
- transformed value (most likely a BigInteger or BigDecimal)
-
convertWhenNotIdentity
Non-API- Parameters:
value
-ctx
-- Returns:
- transformed value
-
convert
public final double convert(double value) - Specified by:
convert
in interfacejavax.measure.UnitConverter
-
convert
- Specified by:
convert
in interfacejavax.measure.UnitConverter
- Throws:
IllegalArgumentException
- if the value is null.
-