Package tech.units.indriya.function
Class AddConverter
java.lang.Object
tech.units.indriya.AbstractConverter
tech.units.indriya.function.AddConverter
- All Implemented Interfaces:
Serializable
,Comparable<javax.measure.UnitConverter>
,javax.measure.UnitConverter
,tech.uom.lib.common.function.ValueSupplier<Double>
public final class AddConverter
extends AbstractConverter
implements tech.uom.lib.common.function.ValueSupplier<Double>
This class represents a converter adding a constant offset to numeric values (double
based).
- Version:
- 1.0, Oct 10, 2016
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class tech.units.indriya.AbstractConverter
AbstractConverter.Pair
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final double
Holds the offset.private static final long
Fields inherited from class tech.units.indriya.AbstractConverter
conversionSteps, IDENTITY
-
Constructor Summary
ConstructorsConstructorDescriptionAddConverter
(double offset) Creates an additive converter having the specified offset. -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(javax.measure.UnitConverter o) double
convertWhenNotIdentity
(double value) Non-APIconvertWhenNotIdentity
(BigDecimal value, MathContext ctx) Non-APIboolean
double
Returns the offset value for this add converter.getValue()
int
hashCode()
Non-APIboolean
boolean
isLinear()
protected boolean
Non-API Guard forAbstractConverter.simpleCompose(AbstractConverter)
protected AbstractConverter
Non-API Guarded byAbstractConverter.isSimpleCompositionWith(AbstractConverter)
Non-APIMethods inherited from class tech.units.indriya.AbstractConverter
concatenate, convert, convert, convertWhenNotIdentity, getConversionSteps, inverse, of, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
offset
private final double offsetHolds the offset.
-
-
Constructor Details
-
AddConverter
public AddConverter(double offset) Creates an additive converter having the specified offset.- Parameters:
offset
- the offset value.
-
-
Method Details
-
getOffset
public double getOffset()Returns the offset value for this add converter.- Returns:
- the offset value.
-
isIdentity
public boolean isIdentity()- Specified by:
isIdentity
in interfacejavax.measure.UnitConverter
-
isSimpleCompositionWith
Description copied from class:AbstractConverter
Non-API Guard forAbstractConverter.simpleCompose(AbstractConverter)
- Specified by:
isSimpleCompositionWith
in classAbstractConverter
- Parameters:
that
-- Returns:
- whether or not a 'simple' composition of transformations is possible
-
simpleCompose
Description copied from class:AbstractConverter
Non-API Guarded byAbstractConverter.isSimpleCompositionWith(AbstractConverter)
- Overrides:
simpleCompose
in classAbstractConverter
- Parameters:
that
-- Returns:
- a new AbstractConverter that adds no additional conversion step
-
inverseWhenNotIdentity
Description copied from class:AbstractConverter
Non-APIReturns an AbstractConverter that represents the inverse transformation of this converter, for cases where the transformation is not the identity transformation.
- Specified by:
inverseWhenNotIdentity
in classAbstractConverter
- Returns:
-
convertWhenNotIdentity
public double convertWhenNotIdentity(double value) Description copied from class:AbstractConverter
Non-API- Specified by:
convertWhenNotIdentity
in classAbstractConverter
- Parameters:
value
-- Returns:
- transformed value
-
convertWhenNotIdentity
public BigDecimal convertWhenNotIdentity(BigDecimal value, MathContext ctx) throws ArithmeticException Description copied from class:AbstractConverter
Non-API- Specified by:
convertWhenNotIdentity
in classAbstractConverter
- Parameters:
value
-ctx
-- Returns:
- transformed value
- Throws:
ArithmeticException
-
transformationLiteral
Description copied from class:AbstractConverter
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.- Specified by:
transformationLiteral
in classAbstractConverter
- Returns:
-
equals
- Specified by:
equals
in classAbstractConverter
-
hashCode
public int hashCode()- Specified by:
hashCode
in classAbstractConverter
-
isLinear
public boolean isLinear()- Specified by:
isLinear
in interfacejavax.measure.UnitConverter
-
getValue
- Specified by:
getValue
in interfacetech.uom.lib.common.function.ValueSupplier<Double>
-
compareTo
public int compareTo(javax.measure.UnitConverter o) - Specified by:
compareTo
in interfaceComparable<javax.measure.UnitConverter>
-