Class JsonNumber
java.lang.Object
io.helidon.json.JsonValue
io.helidon.json.JsonNumber
Represents a JSON number value.
Equality follows
BigDecimal.equals(Object), including its scale-sensitive semantics.-
Method Summary
Modifier and TypeMethodDescriptionReturn the BigDecimal value of this JsonNumber.Return the BigInteger value of this JsonNumber.byteReturn the byte value of this JsonNumber.static JsonNumbercreate(double doubleValue) Create a JsonNumber from a double value.static JsonNumbercreate(long longValue) Create a JsonNumber from a long value.static JsonNumbercreate(BigDecimal bigDecimalValue) Create a JsonNumber from a BigDecimal value.doubleReturn the double value of this JsonNumber.booleanfloatReturn the float value of this JsonNumber.inthashCode()intintValue()Return the int value of this JsonNumber.longReturn the long value of this JsonNumber.shortReturn the short value of this JsonNumber.voidtoJson(JsonGenerator generator) Write this JSON value to the provided generator.type()Return the type of this JSON value.Methods inherited from class JsonValue
asArray, asBoolean, asNumber, asObject, asString, objectBuilder, toStringModifier and TypeMethodDescriptionasArray()Cast this value to a JsonArray if it is of array type.Cast this value to a JsonBoolean if it is of boolean type.asNumber()Cast this value to a JsonNumber if it is of number type.asObject()Cast this value to a JsonObject if it is of object type.asString()Cast this value to a JsonString if it is of string type.static JsonObject.BuilderA new fluent API builder to construct anJsonObject.toString()
-
Method Details
-
create
Create a JsonNumber from a BigDecimal value.- Parameters:
bigDecimalValue- the BigDecimal value- Returns:
- a new JsonNumber
-
create
Create a JsonNumber from a double value.- Parameters:
doubleValue- the double value- Returns:
- a new JsonNumber
-
create
Create a JsonNumber from a long value.- Parameters:
longValue- the long value- Returns:
- a new JsonNumber
-
doubleValue
public double doubleValue()Return the double value of this JsonNumber. This conversion may lose precision or return an infinity if the magnitude is too large.- Returns:
- the double value
- See Also:
-
byteValue
public byte byteValue()Return the byte value of this JsonNumber. Any fractional part is discarded. If the resulting integer does not fit, only the low-order 8 bits are returned, so the result may have the opposite sign.- Returns:
- the byte value
- See Also:
-
shortValue
public short shortValue()Return the short value of this JsonNumber. Any fractional part is discarded. If the resulting integer does not fit, only the low-order 16 bits are returned, so the result may have the opposite sign.- Returns:
- the short value
- See Also:
-
intValue
public int intValue()Return the int value of this JsonNumber. Any fractional part is discarded. If the resulting integer does not fit, only the low-order 32 bits are returned, so the result may have the opposite sign.- Returns:
- the int value
- See Also:
-
longValue
public long longValue()Return the long value of this JsonNumber. Any fractional part is discarded. If the resulting integer does not fit, only the low-order 64 bits are returned, so the result may have the opposite sign.- Returns:
- the long value
- See Also:
-
floatValue
public float floatValue()Return the float value of this JsonNumber. This conversion may lose precision or return an infinity if the magnitude is too large.- Returns:
- the float value
- See Also:
-
bigIntegerValue
Return the BigInteger value of this JsonNumber. Any fractional part is discarded.For a nonzero value with a negative scale, a conversion may introduce at most 4,096 trailing decimal digits. Numbers originating from the same parsed JSON document also share a cumulative budget of 65,536 such digits; every invocation consumes that document budget. Programmatically created numbers have only the per-conversion limit.
- Returns:
- the BigInteger value
- Throws:
JsonException- if the conversion exceeds the per-value or parsed-document expansion budget- See Also:
-
bigDecimalValue
Return the BigDecimal value of this JsonNumber.- Returns:
- the BigDecimal value
-
type
Description copied from class:JsonValueReturn the type of this JSON value. -
equals
-
hashCode
-
toJson
Description copied from class:JsonValueWrite this JSON value to the provided generator.
-