public final class RationalConverter extends AbstractConverter implements tech.uom.lib.common.function.ValueSupplier<Double>, Supplier<Double>, DoubleSupplier
This class represents a converter multiplying numeric values by an exact scaling factor (represented as the quotient of two BigInteger
numbers).
AbstractConverter.PairconversionSteps, IDENTITY| Constructor and Description |
|---|
RationalConverter(BigInteger dividend,
BigInteger divisor)
Creates a rational converter with the specified dividend and divisor.
|
RationalConverter(long dividend,
long divisor)
Convenience method equivalent to
new RationalConverter(BigInteger.valueOf(dividend), BigInteger.valueOf(divisor)) |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(javax.measure.UnitConverter o) |
BigDecimal |
convertWhenNotIdentity(BigDecimal value,
MathContext ctx)
Non-API
|
protected Number |
convertWhenNotIdentity(BigInteger value,
MathContext ctx)
Non-API
|
double |
convertWhenNotIdentity(double value)
Non-API
|
boolean |
equals(Object obj) |
Double |
get() |
double |
getAsDouble() |
BigInteger |
getDividend()
Returns the integer dividend for this rational converter.
|
BigInteger |
getDivisor()
Returns the integer (positive) divisor for this rational converter.
|
Double |
getValue() |
int |
hashCode() |
RationalConverter |
inverseWhenNotIdentity()
Non-API
|
boolean |
isIdentity() |
boolean |
isLinear() |
protected boolean |
isSimpleCompositionWith(AbstractConverter that)
Non-API
Guard for
AbstractConverter.simpleCompose(AbstractConverter) |
static RationalConverter |
of(BigInteger dividend,
BigInteger divisor)
Convenience method equivalent to
new RationalConverter(dividend, divisor) |
static RationalConverter |
of(double dividend,
double divisor)
Convenience method equivalent to
new RationalConverter(BigDecimal.valueOf(dividend).toBigInteger(),
BigDecimal.valueOf(divisor).toBigInteger()) |
static RationalConverter |
of(long dividend,
long divisor)
Convenience method equivalent to
new RationalConverter(dividend, divisor) |
protected AbstractConverter |
simpleCompose(AbstractConverter that)
Non-API
Guarded by
AbstractConverter.isSimpleCompositionWith(AbstractConverter) |
String |
transformationLiteral()
Non-API
|
concatenate, convert, convert, getConversionSteps, inverse, of, toStringpublic RationalConverter(BigInteger dividend, BigInteger divisor)
dividend - the dividend.divisor - the positive divisor.IllegalArgumentException - if divisor <= 0public RationalConverter(long dividend, long divisor)
new RationalConverter(BigInteger.valueOf(dividend), BigInteger.valueOf(divisor))dividend - the dividend.divisor - the positive divisor.IllegalArgumentException - if divisor <= 0IllegalArgumentException - if dividend == divisorpublic static RationalConverter of(BigInteger dividend, BigInteger divisor)
new RationalConverter(dividend, divisor)dividend - the dividend.divisor - the positive divisor.IllegalArgumentException - if divisor <= 0IllegalArgumentException - if dividend == divisorpublic static RationalConverter of(long dividend, long divisor)
new RationalConverter(dividend, divisor)dividend - the dividend.divisor - the positive divisor.IllegalArgumentException - if divisor <= 0IllegalArgumentException - if dividend == divisorpublic static RationalConverter of(double dividend, double divisor)
new RationalConverter(BigDecimal.valueOf(dividend).toBigInteger(),
BigDecimal.valueOf(divisor).toBigInteger())dividend - the dividend.divisor - the positive divisor.IllegalArgumentException - if divisor <= 0IllegalArgumentException - if dividend == divisorpublic BigInteger getDividend()
public BigInteger getDivisor()
public double convertWhenNotIdentity(double value)
AbstractConverterconvertWhenNotIdentity in class AbstractConverterprotected Number convertWhenNotIdentity(BigInteger value, MathContext ctx)
AbstractConverterconvertWhenNotIdentity in class AbstractConverterpublic BigDecimal convertWhenNotIdentity(BigDecimal value, MathContext ctx) throws ArithmeticException
AbstractConverterconvertWhenNotIdentity in class AbstractConverterArithmeticExceptionpublic boolean isIdentity()
isIdentity in interface javax.measure.UnitConverterprotected boolean isSimpleCompositionWith(AbstractConverter that)
AbstractConverterAbstractConverter.simpleCompose(AbstractConverter)isSimpleCompositionWith in class AbstractConverterprotected AbstractConverter simpleCompose(AbstractConverter that)
AbstractConverterAbstractConverter.isSimpleCompositionWith(AbstractConverter)simpleCompose in class AbstractConverterpublic RationalConverter inverseWhenNotIdentity()
AbstractConverterReturns an AbstractConverter that represents the inverse transformation of this converter, for cases where the transformation is not the identity transformation.
inverseWhenNotIdentity in class AbstractConverterpublic final String transformationLiteral()
AbstractConverter
Returns a String describing the transformation that is represented by this converter.
Contributes to converter's toString method. If null or empty
toString output becomes simplified.
transformationLiteral in class AbstractConverterpublic boolean equals(Object obj)
equals in class AbstractConverterpublic int hashCode()
hashCode in class AbstractConverterpublic boolean isLinear()
isLinear in interface javax.measure.UnitConverterpublic Double getValue()
getValue in interface tech.uom.lib.common.function.ValueSupplier<Double>public double getAsDouble()
getAsDouble in interface DoubleSupplierpublic int compareTo(javax.measure.UnitConverter o)
compareTo in interface Comparable<javax.measure.UnitConverter>Copyright © 2005–2018 Units of Measurement project. All rights reserved.