Package io.kjson
Class JSONNumber
-
- All Implemented Interfaces:
-
io.kjson.JSONValue,java.io.Serializable
public class JSONNumber extends Number implements JSONValue
An abstract base class for the three number types of JSON value. It includes functions to assist with conversion between number types.
-
-
Method Summary
Modifier and Type Method Description abstract NumbergetValue()The value (will be overridden by a value of a specific type). abstract BooleanisIntegral()Return trueif the value is integral (has no fractional part, or the fractional part is zero).abstract BooleanisLong()Return trueif the value will fit in aLong.abstract BooleanisInt()Return trueif the value will fit in anInt.abstract BooleanisShort()Return trueif the value will fit in aShort.abstract BooleanisByte()Return trueif the value will fit in aByte.abstract BooleanisULong()Return trueif the value will fit in aULong.abstract BooleanisUInt()Return trueif the value will fit in aUInt.abstract BooleanisUShort()Return trueif the value will fit in aUShort.abstract BooleanisUByte()Return trueif the value will fit in aUByte.abstract BooleanisZero()Return trueif the value is zero.abstract BooleanisNegative()Return trueif the value is negative.abstract BooleanisPositive()Return trueif the value is positive.abstract BooleanisNotZero()Return trueif the value is not zero.abstract BooleanisNotNegative()Return trueif the value is not negative.abstract BooleanisNotPositive()Return trueif the value is not positive.abstract BigDecimaltoDecimal()Convert the value to BigDecimal. abstract ULongtoULong()Convert the value to ULong. abstract UInttoUInt()Convert the value to UInt. abstract UShorttoUShort()Convert the value to UShort. abstract UBytetoUByte()Convert the value to UByte. abstract Booleanequals(Object other)Compare the value to another JSONNumber value. abstract IntegerhashCode()Get the hash code for the JSONNumber value. -
Methods inherited from class kotlin.Number
toByte, toChar, toDouble, toFloat, toInt, toLong, toShort -
Methods inherited from class io.kjson.JSONValue
appendTo, coOutput, coOutputTo, output, outputTo, toJSON -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
isIntegral
abstract Boolean isIntegral()
Return
trueif the value is integral (has no fractional part, or the fractional part is zero).
-
isNegative
abstract Boolean isNegative()
Return
trueif the value is negative.
-
isPositive
abstract Boolean isPositive()
Return
trueif the value is positive.
-
isNotNegative
abstract Boolean isNotNegative()
Return
trueif the value is not negative.
-
isNotPositive
abstract Boolean isNotPositive()
Return
trueif the value is not positive.
-
toDecimal
abstract BigDecimal toDecimal()
Convert the value to BigDecimal.
-
equals
abstract Boolean equals(Object other)
Compare the value to another JSONNumber value. JSONNumber objects with different types but the same value are considered equal.
-
hashCode
abstract Integer hashCode()
Get the hash code for the JSONNumber value. JSONNumber objects with different types but the same value will return the same hash code.
-
-
-
-