Package tech.units.indriya.function
Class LogConverter
- java.lang.Object
-
- tech.units.indriya.AbstractConverter
-
- tech.units.indriya.function.LogConverter
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<javax.measure.UnitConverter>
,javax.measure.UnitConverter
,tech.uom.lib.common.function.ValueSupplier<java.lang.String>
public final class LogConverter extends AbstractConverter implements tech.uom.lib.common.function.ValueSupplier<java.lang.String>
This class represents a logarithmic converter of limited precision. Such converter is typically used to create logarithmic unit. For example:
Unit
BEL = Unit.ONE.transform(new LogConverter(10).inverse()); - Since:
- 1.0
- Version:
- 1.0.1, December 28, 2017
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class tech.units.indriya.AbstractConverter
AbstractConverter.Pair
-
-
Field Summary
Fields Modifier and Type Field Description private double
base
Holds the logarithmic base.private double
logOfBase
Holds the natural logarithm of the base.private static long
serialVersionUID
-
Fields inherited from class tech.units.indriya.AbstractConverter
conversionSteps, IDENTITY
-
-
Constructor Summary
Constructors Constructor Description LogConverter(double base)
Returns a logarithmic converter having the specified base.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(javax.measure.UnitConverter o)
double
convertWhenNotIdentity(double amount)
Non-APIjava.math.BigDecimal
convertWhenNotIdentity(java.math.BigDecimal value, java.math.MathContext ctx)
Non-APIboolean
equals(java.lang.Object obj)
double
getBase()
Returns the logarithmic base of this converter.java.lang.String
getValue()
int
hashCode()
AbstractConverter
inverseWhenNotIdentity()
Non-APIboolean
isIdentity()
boolean
isLinear()
protected boolean
isSimpleCompositionWith(AbstractConverter that)
Non-API Guard forAbstractConverter.simpleCompose(AbstractConverter)
protected AbstractConverter
simpleCompose(AbstractConverter that)
Non-API Guarded byAbstractConverter.isSimpleCompositionWith(AbstractConverter)
java.lang.String
transformationLiteral()
Non-API-
Methods inherited from class tech.units.indriya.AbstractConverter
concatenate, convert, convert, convertWhenNotIdentity, getConversionSteps, inverse, of, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
base
private final double base
Holds the logarithmic base.
-
logOfBase
private final double logOfBase
Holds the natural logarithm of the base.
-
-
Method Detail
-
getBase
public double getBase()
Returns the logarithmic base of this converter.- Returns:
- the logarithmic base (e.g.
Math.E
for the Natural Logarithm).
-
isIdentity
public boolean isIdentity()
- Specified by:
isIdentity
in interfacejavax.measure.UnitConverter
-
isSimpleCompositionWith
protected boolean isSimpleCompositionWith(AbstractConverter that)
Description copied from class:AbstractConverter
Non-API Guard forAbstractConverter.simpleCompose(AbstractConverter)
- Specified by:
isSimpleCompositionWith
in classAbstractConverter
- Returns:
- whether or not a 'simple' composition of transformations is possible
-
simpleCompose
protected AbstractConverter simpleCompose(AbstractConverter that)
Description copied from class:AbstractConverter
Non-API Guarded byAbstractConverter.isSimpleCompositionWith(AbstractConverter)
- Overrides:
simpleCompose
in classAbstractConverter
- Returns:
- a new AbstractConverter that adds no additional conversion step
-
inverseWhenNotIdentity
public AbstractConverter 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:
-
transformationLiteral
public final java.lang.String 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
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in classAbstractConverter
-
hashCode
public int hashCode()
- Specified by:
hashCode
in classAbstractConverter
-
convertWhenNotIdentity
public double convertWhenNotIdentity(double amount)
Description copied from class:AbstractConverter
Non-API- Specified by:
convertWhenNotIdentity
in classAbstractConverter
- Returns:
- transformed value
-
convertWhenNotIdentity
public java.math.BigDecimal convertWhenNotIdentity(java.math.BigDecimal value, java.math.MathContext ctx) throws java.lang.ArithmeticException
Description copied from class:AbstractConverter
Non-API- Specified by:
convertWhenNotIdentity
in classAbstractConverter
- Returns:
- transformed value
- Throws:
java.lang.ArithmeticException
-
isLinear
public boolean isLinear()
- Specified by:
isLinear
in interfacejavax.measure.UnitConverter
-
getValue
public java.lang.String getValue()
- Specified by:
getValue
in interfacetech.uom.lib.common.function.ValueSupplier<java.lang.String>
-
compareTo
public int compareTo(javax.measure.UnitConverter o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<javax.measure.UnitConverter>
-
-