Package tech.units.indriya.function
Class PowersOfIntConverter
java.lang.Object
tech.units.indriya.AbstractConverter
tech.units.indriya.function.PowersOfIntConverter
- All Implemented Interfaces:
Serializable
,Comparable<javax.measure.UnitConverter>
,javax.measure.UnitConverter
UnitConverter for numbers in base^exponent representation.
- Since:
- 2.0
- Version:
- 1.1, April 24, 2018
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class tech.units.indriya.AbstractConverter
AbstractConverter.Pair
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
private final double
private final int
private final int
private static final long
Fields inherited from class tech.units.indriya.AbstractConverter
conversionSteps, IDENTITY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(javax.measure.UnitConverter o) private PowersOfIntConverter
double
convertWhenNotIdentity
(double value) Non-APIconvertWhenNotIdentity
(BigDecimal value, MathContext ctx) Non-APIprotected Number
convertWhenNotIdentity
(BigInteger value, MathContext ctx) Non-APIboolean
int
getBase()
int
int
hashCode()
Non-APIboolean
boolean
isLinear()
protected boolean
Non-API Guard forAbstractConverter.simpleCompose(AbstractConverter)
static PowersOfIntConverter
of
(int base, int exponent) Creates a converter with a factor represented by specified base^exponent.static PowersOfIntConverter
Creates a converter with the specified Prefix.protected AbstractConverter
Non-API Guarded byAbstractConverter.isSimpleCompositionWith(AbstractConverter)
final String
Non-APIMethods inherited from class tech.units.indriya.AbstractConverter
concatenate, convert, convert, getConversionSteps, inverse, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
base
private final int base -
exponent
private final int exponent -
hashCode
private final int hashCode -
doubleFactor
private final double doubleFactor
-
-
Constructor Details
-
PowersOfIntConverter
protected PowersOfIntConverter(int base, int exponent)
-
-
Method Details
-
of
Creates a converter with the specified Prefix.- Parameters:
prefix
- the prefix for the factor.
-
of
Creates a converter with a factor represented by specified base^exponent.- Parameters:
base
-exponent
-- Returns:
-
getBase
public int getBase() -
getExponent
public int getExponent() -
isIdentity
public boolean isIdentity() -
isLinear
public boolean isLinear() -
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
Description copied from class:AbstractConverter
Non-API- Overrides:
convertWhenNotIdentity
in classAbstractConverter
- Parameters:
value
-ctx
-- Returns:
- transformed value (most likely a BigInteger or BigDecimal)
-
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
-
convertWhenNotIdentity
public double convertWhenNotIdentity(double value) Description copied from class:AbstractConverter
Non-API- Specified by:
convertWhenNotIdentity
in classAbstractConverter
- Parameters:
value
-- Returns:
- transformed value
-
equals
- Specified by:
equals
in classAbstractConverter
-
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:
-
compareTo
public int compareTo(javax.measure.UnitConverter o) -
hashCode
public int hashCode()- Specified by:
hashCode
in classAbstractConverter
-
composeSameBaseNonIdentity
-
toRationalConverter
-