Package tech.units.indriya.function
Class PowersOfIntConverter
- java.lang.Object
-
- tech.units.indriya.AbstractConverter
-
- tech.units.indriya.function.PowersOfIntConverter
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<javax.measure.UnitConverter>,javax.measure.UnitConverter
public final class PowersOfIntConverter extends AbstractConverter
UnitConverter for numbers in base^exponent representation.- Since:
- 2.0
- Version:
- 1.1, April 24, 2018
- 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 intbaseprivate doubledoubleFactorprivate intexponentprivate inthashCodeprivate static longserialVersionUID-
Fields inherited from class tech.units.indriya.AbstractConverter
conversionSteps, IDENTITY
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPowersOfIntConverter(int base, int exponent)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(javax.measure.UnitConverter o)private PowersOfIntConvertercomposeSameBaseNonIdentity(PowersOfIntConverter other)doubleconvertWhenNotIdentity(double value)Non-APIjava.math.BigDecimalconvertWhenNotIdentity(java.math.BigDecimal value, java.math.MathContext ctx)Non-APIprotected java.lang.NumberconvertWhenNotIdentity(java.math.BigInteger value, java.math.MathContext ctx)Non-APIbooleanequals(java.lang.Object obj)intgetBase()intgetExponent()inthashCode()AbstractConverterinverseWhenNotIdentity()Non-APIbooleanisIdentity()booleanisLinear()protected booleanisSimpleCompositionWith(AbstractConverter that)Non-API Guard forAbstractConverter.simpleCompose(AbstractConverter)static PowersOfIntConverterof(int base, int exponent)Creates a converter with a factor represented by specified base^exponent.static PowersOfIntConverterof(Prefix prefix)Creates a converter with the specified Prefix.protected AbstractConvertersimpleCompose(AbstractConverter that)Non-API Guarded byAbstractConverter.isSimpleCompositionWith(AbstractConverter)RationalConvertertoRationalConverter()java.lang.StringtransformationLiteral()Non-API-
Methods inherited from class tech.units.indriya.AbstractConverter
concatenate, convert, convert, getConversionSteps, inverse, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
base
private final int base
-
exponent
private final int exponent
-
hashCode
private final int hashCode
-
doubleFactor
private final double doubleFactor
-
-
Method Detail
-
of
public static PowersOfIntConverter of(Prefix prefix)
Creates a converter with the specified Prefix.- Parameters:
prefix- the prefix for the factor.
-
of
public static PowersOfIntConverter of(int base, int exponent)
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
protected boolean isSimpleCompositionWith(AbstractConverter that)
Description copied from class:AbstractConverterNon-API Guard forAbstractConverter.simpleCompose(AbstractConverter)- Specified by:
isSimpleCompositionWithin classAbstractConverter- Returns:
- whether or not a 'simple' composition of transformations is possible
-
simpleCompose
protected AbstractConverter simpleCompose(AbstractConverter that)
Description copied from class:AbstractConverterNon-API Guarded byAbstractConverter.isSimpleCompositionWith(AbstractConverter)- Overrides:
simpleComposein classAbstractConverter- Returns:
- a new AbstractConverter that adds no additional conversion step
-
inverseWhenNotIdentity
public AbstractConverter inverseWhenNotIdentity()
Description copied from class:AbstractConverterNon-APIReturns an AbstractConverter that represents the inverse transformation of this converter, for cases where the transformation is not the identity transformation.
- Specified by:
inverseWhenNotIdentityin classAbstractConverter- Returns:
-
convertWhenNotIdentity
protected java.lang.Number convertWhenNotIdentity(java.math.BigInteger value, java.math.MathContext ctx)Description copied from class:AbstractConverterNon-API- Overrides:
convertWhenNotIdentityin classAbstractConverter- Returns:
- transformed value (most likely a BigInteger or BigDecimal)
-
convertWhenNotIdentity
public java.math.BigDecimal convertWhenNotIdentity(java.math.BigDecimal value, java.math.MathContext ctx) throws java.lang.ArithmeticExceptionDescription copied from class:AbstractConverterNon-API- Specified by:
convertWhenNotIdentityin classAbstractConverter- Returns:
- transformed value
- Throws:
java.lang.ArithmeticException
-
convertWhenNotIdentity
public double convertWhenNotIdentity(double value)
Description copied from class:AbstractConverterNon-API- Specified by:
convertWhenNotIdentityin classAbstractConverter- Returns:
- transformed value
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin classAbstractConverter
-
transformationLiteral
public final java.lang.String transformationLiteral()
Description copied from class:AbstractConverterNon-APIReturns a String describing the transformation that is represented by this converter. Contributes to converter's
toStringmethod. If null or emptytoStringoutput becomes simplified.- Specified by:
transformationLiteralin classAbstractConverter- Returns:
-
compareTo
public int compareTo(javax.measure.UnitConverter o)
-
hashCode
public int hashCode()
- Specified by:
hashCodein classAbstractConverter
-
composeSameBaseNonIdentity
private PowersOfIntConverter composeSameBaseNonIdentity(PowersOfIntConverter other)
-
toRationalConverter
public RationalConverter toRationalConverter()
-
-