public final class RationalConverter extends AbstractConverter implements tec.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.PairIDENTITY, PI| 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 |
|---|---|
javax.measure.UnitConverter |
concatenate(javax.measure.UnitConverter converter) |
BigDecimal |
convert(BigDecimal value,
MathContext ctx) |
double |
convert(double value) |
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 |
inverse() |
boolean |
isLinear() |
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) |
String |
toString() |
concatenate, convert, getConversionSteps, isIdentitypublic RationalConverter(BigInteger dividend, BigInteger divisor)
dividend - the dividend.divisor - the positive divisor.IllegalArgumentException - if divisor <= 0IllegalArgumentException - if dividend == divisorpublic 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 convert(double value)
convert in interface javax.measure.UnitConverterconvert in class AbstractConverterpublic BigDecimal convert(BigDecimal value, MathContext ctx) throws ArithmeticException
convert in class AbstractConverterArithmeticExceptionpublic javax.measure.UnitConverter concatenate(javax.measure.UnitConverter converter)
concatenate in interface javax.measure.UnitConverterconcatenate in class AbstractConverterpublic RationalConverter inverse()
inverse in interface javax.measure.UnitConverterinverse 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 tec.uom.lib.common.function.ValueSupplier<Double>public double getAsDouble()
getAsDouble in interface DoubleSupplierCopyright © 2005–2017 Units of Measurement project. All rights reserved.