Class Decimal64
- java.lang.Object
-
- java.lang.Number
-
- org.opendaylight.yangtools.yang.common.Decimal64
-
- All Implemented Interfaces:
Serializable
,Comparable<Decimal64>
,Immutable
,MutationBehaviour<Immutable>
,CanonicalValue<Decimal64>
@Beta @NonNullByDefault public class Decimal64 extends Number implements CanonicalValue<Decimal64>
Dedicated type for YANG's 'type decimal64' type. This class is similar toBigDecimal
, but provides more efficient storage, as it has fixed precision.- Author:
- Robert Varga
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Decimal64.Support
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte
byteValueExact()
Converts thisBigDecimal
to abyte
, checking for lost information.int
compareTo(Decimal64 o)
BigDecimal
decimalValue()
double
doubleValue()
boolean
equals(@Nullable Object obj)
boolean
equals(@Nullable Decimal64 obj)
A slightly faster version ofequals(Object)
.float
floatValue()
int
hashCode()
int
intValue()
int
intValueExact()
Converts thisBigDecimal
to anint
, checking for lost information.long
longValue()
long
longValueExact()
Converts thisBigDecimal
to along
, checking for lost information.short
shortValueExact()
Converts thisBigDecimal
to ashort
, checking for lost information.CanonicalValueSupport<Decimal64>
support()
Return theCanonicalValue
associated with this type.String
toCanonicalString()
Return the canonical string representation of this value.String
toString()
static Decimal64
valueOf(byte byteVal)
static Decimal64
valueOf(double doubleVal)
static Decimal64
valueOf(int intVal)
static Decimal64
valueOf(long longVal)
static Decimal64
valueOf(short shortVal)
static Decimal64
valueOf(String str)
Attempt to parse a String into a Decimal64.static Decimal64
valueOf(BigDecimal decimalVal)
-
Methods inherited from class java.lang.Number
byteValue, shortValue
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.opendaylight.yangtools.yang.common.CanonicalValue
validator
-
-
-
-
Constructor Detail
-
Decimal64
protected Decimal64(Decimal64 other)
-
-
Method Detail
-
valueOf
public static Decimal64 valueOf(byte byteVal)
-
valueOf
public static Decimal64 valueOf(short shortVal)
-
valueOf
public static Decimal64 valueOf(int intVal)
-
valueOf
public static Decimal64 valueOf(long longVal)
-
valueOf
public static Decimal64 valueOf(double doubleVal)
-
valueOf
public static Decimal64 valueOf(BigDecimal decimalVal)
-
valueOf
public static Decimal64 valueOf(String str)
Attempt to parse a String into a Decimal64. This method uses minimum fraction digits required to hold the entire value.- Parameters:
str
- String to parser- Returns:
- A Decimal64 instance
- Throws:
NullPointerException
- if value is null.NumberFormatException
- if the string does not contain a parsable decimal64.
-
decimalValue
public final BigDecimal decimalValue()
-
floatValue
public final float floatValue()
- Specified by:
floatValue
in classNumber
-
doubleValue
public final double doubleValue()
- Specified by:
doubleValue
in classNumber
-
byteValueExact
public final byte byteValueExact()
Converts thisBigDecimal
to abyte
, checking for lost information. If thisDecimal64
has a nonzero fractional part or is out of the possible range for abyte
result then anArithmeticException
is thrown.- Returns:
- this
Decimal64
converted to abyte
. - Throws:
ArithmeticException
- ifthis
has a nonzero fractional part, or will not fit in abyte
.
-
shortValueExact
public final short shortValueExact()
Converts thisBigDecimal
to ashort
, checking for lost information. If thisDecimal64
has a nonzero fractional part or is out of the possible range for ashort
result then anArithmeticException
is thrown.- Returns:
- this
Decimal64
converted to ashort
. - Throws:
ArithmeticException
- ifthis
has a nonzero fractional part, or will not fit in ashort
.
-
intValueExact
public final int intValueExact()
Converts thisBigDecimal
to anint
, checking for lost information. If thisDecimal64
has a nonzero fractional part or is out of the possible range for anint
result then anArithmeticException
is thrown.- Returns:
- this
Decimal64
converted to anint
. - Throws:
ArithmeticException
- ifthis
has a nonzero fractional part, or will not fit in anint
.
-
longValueExact
public final long longValueExact()
Converts thisBigDecimal
to along
, checking for lost information. If thisDecimal64
has a nonzero fractional part then anArithmeticException
is thrown.- Returns:
- this
Decimal64
converted to along
. - Throws:
ArithmeticException
- ifthis
has a nonzero fractional part.
-
compareTo
public final int compareTo(Decimal64 o)
- Specified by:
compareTo
in interfaceComparable<Decimal64>
-
toCanonicalString
public final String toCanonicalString()
Description copied from interface:CanonicalValue
Return the canonical string representation of this value.- Specified by:
toCanonicalString
in interfaceCanonicalValue<Decimal64>
- Returns:
- Canonical string
-
support
public final CanonicalValueSupport<Decimal64> support()
Description copied from interface:CanonicalValue
Return theCanonicalValue
associated with this type. It can be used to create new instances of this representation.- Specified by:
support
in interfaceCanonicalValue<Decimal64>
- Returns:
- A
CanonicalValue
instance.
-
equals
public final boolean equals(@Nullable Decimal64 obj)
A slightly faster version ofequals(Object)
.- Parameters:
obj
- Decimal64 object- Returns:
true
if this object is the same as the obj argument;false
otherwise.
-
-