Class SdkNumber
java.lang.Object
java.lang.Number
software.amazon.awssdk.core.SdkNumber
- All Implemented Interfaces:
Serializable
An in-memory representation of Number being given to a service or being returned by a service.
This is a SDK representation of a Number. This allows conversion to any desired numeric type by providing constructors
as below
fromBigDecimal(BigDecimal)to create from a BigDecimal.fromBigInteger(BigInteger)to create from a BigInteger.fromDouble(double)to create from a doublefromFloat(float)to create from a float.fromLong(long)to create from a long.fromShort(short)to create from a short.fromInteger(int)to create from an integer.fromString(String)to create from a String
If SdkNumber is expected in a particular number format then its corresponding getter methods can be used.
Example for a SdkNumber created with BigDecimal the
fromBigDecimal(BigDecimal) can be used.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionGets the bigDecimalValue of theSdkNumber.doubleGets the double value of theSdkNumber.booleanfloatGets the float value of theSdkNumber.static SdkNumberfromBigDecimal(BigDecimal bigDecimalValue) CreateSdkNumberfrom a BigDecimal value.static SdkNumberfromBigInteger(BigInteger bigIntegerValue) CreateSdkNumberfrom a BigInteger value.static SdkNumberfromDouble(double doubleValue) CreateSdkNumberfrom a double Value.static SdkNumberfromFloat(float floatValue) CreateSdkNumberfrom a float Value.static SdkNumberfromInteger(int integerValue) CreateSdkNumberfrom a integer value.static SdkNumberfromLong(long longValue) CreateSdkNumberfrom a long Value.static SdkNumberfromShort(short shortValue) CreateSdkNumberfrom a long Value.static SdkNumberfromString(String stringValue) CreateSdkNumberfrom a long Value.inthashCode()intintValue()Gets the integer value of theSdkNumber.longGets the long value of theSdkNumber.Gets the String value of theSdkNumber.toString()Methods inherited from class java.lang.Number
byteValue, shortValue
-
Method Details
-
fromInteger
-
fromBigInteger
-
fromBigDecimal
-
fromLong
-
fromDouble
-
fromShort
-
fromFloat
-
fromString
-
intValue
public int intValue()Gets the integer value of theSdkNumber. If we do a intValue() forSdkNumberconstructed from float, double, long, BigDecimal, BigInteger number type then it may result in loss of magnitude and a loss of precision. The result may lose some of the least significant bits of the value. Precision is not lost while getting aSdkNumberwhich was constructed as lower precision number type like short, byte, integer. -
longValue
public long longValue()Gets the long value of theSdkNumber. If we do a longValue() forSdkNumberconstructed from float, double, BigDecimal, BigInteger number type then it may result in loss of magnitude and a loss of precision. Precision is not lost while getting aSdkNumberwhich was constructed from lower precision type like short, byte, integer. -
floatValue
public float floatValue()Gets the float value of theSdkNumber. If we do a floatValue() forSdkNumberconstructed from double, BigDecimal, BigInteger number type then it may result in loss of magnitude and a loss of precision. Precision is not lost while getting aSdkNumberwhich was constructed from precision type like short, byte, integer, long.- Specified by:
floatValuein classNumber- Returns:
- long value of
SdkNumber.
-
doubleValue
public double doubleValue()Gets the double value of theSdkNumber. If we do a doubleValue() forSdkNumberconstructed from BigDecimal, BigInteger number type then it may result in loss of magnitude and a loss of precision. Precision is not lost while getting aSdkNumberwhich was constructed from precision type like short, byte, integer, long, float.- Specified by:
doubleValuein classNumber- Returns:
- long value of
SdkNumber.
-
bigDecimalValue
Gets the bigDecimalValue of theSdkNumber. Precision is not lost in this case. However bigDecimalValue cannot be performed on a {SdkNumber} constructed from Float/Double Nan/Infinity.- Returns:
- BigDecimal value of
SdkNumber - Throws:
NumberFormatException- Exception in thrown if aSdkNumberwas constructed asNan/Infinte number of Double/FLoat type.Since we cannot convert NaN/Infinite numbers to BigDecimal.
-
stringValue
-
toString
-
equals
-
hashCode
-