Class JSONInt
-
- All Implemented Interfaces:
-
io.kjson.JSONPrimitive,io.kjson.JSONValue,java.io.Serializable
public final class JSONInt extends JSONNumber implements JSONPrimitive<Int>
A JSON integer value (up to 32 bits).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classJSONInt.Companion
-
Field Summary
Fields Modifier and Type Field Description private final IntegerasIntprivate final IntegerasIntOrNullprivate final LongasLongprivate final LongasLongOrNullprivate final BigDecimalasDecimalprivate final BigDecimalasDecimalOrNullprivate final Integervaluepublic final static JSONInt.CompanionCompanion
-
Method Summary
Modifier and Type Method Description final IntegergetAsInt()final IntegergetAsIntOrNull()final LonggetAsLong()final LonggetAsLongOrNull()final BigDecimalgetAsDecimal()final BigDecimalgetAsDecimalOrNull()IntegergetValue()The value (will be overridden by a value of a specific type). UnitappendTo(Appendable a)Append as a JSON string to an Appendable. StringtoJSON()Convert to a JSON string. UnitoutputTo(IntConsumer out)Output as a JSON string to an IntConsumer. Unitoutput(IntConsumer out)Output as a JSON string to an IntConsumer. UnitcoOutputTo(SuspendFunction1<Character, Unit> out)Output as a JSON string to a CoOutput. UnitcoOutput(SuspendFunction1<Character, Unit> out)Output as a JSON string to a CoOutput. BooleanisIntegral()Return trueif the value is integral (has no fractional part, or the fractional part is zero).BooleanisLong()Return trueif the value is will fit in aLong.BooleanisInt()Return trueif the value is will fit in anInt.BooleanisShort()Return trueif the value is will fit in aShort.BooleanisByte()Return trueif the value is will fit in aByte.BooleanisULong()Return trueif the value is will fit in aULong.BooleanisUInt()Return trueif the value is will fit in aUInt.BooleanisUShort()Return trueif the value is will fit in aUShort.BooleanisUByte()Return trueif the value is will fit in aUByte.BooleanisZero()Return trueif the value is zero.BooleanisNegative()Return trueif the value is negative.BooleanisPositive()Return trueif the value is positive.BooleanisNotZero()Return trueif the value is not zero.BooleanisNotNegative()Return trueif the value is not negative.BooleanisNotPositive()Return trueif the value is not positive.DoubletoDouble()Convert the value to Double. FloattoFloat()Convert the value to Float. LongtoLong()Convert the value to Long. IntegertoInt()Convert the value to Int. CharactertoChar()Convert the value to Char. ShorttoShort()Convert the value to Short. BytetoByte()Convert the value to Byte. BigDecimaltoDecimal()Convert the value to BigDecimal. ULongtoULong()Convert the value to ULong. UInttoUInt()Convert the value to UInt. UShorttoUShort()Convert the value to UShort. UBytetoUByte()Convert the value to UByte. Booleanequals(Object other)Compare the value to another JSONNumber value. IntegerhashCode()Get the hash code for the JSONNumber value. StringtoString()Convert the value to String. -
-
Constructor Detail
-
JSONInt
JSONInt(Integer value)
-
-
Method Detail
-
getAsIntOrNull
final Integer getAsIntOrNull()
-
getAsLongOrNull
final Long getAsLongOrNull()
-
getAsDecimal
final BigDecimal getAsDecimal()
-
getAsDecimalOrNull
final BigDecimal getAsDecimalOrNull()
-
appendTo
Unit appendTo(Appendable a)
Append as a JSON string to an Appendable.
-
outputTo
Unit outputTo(IntConsumer out)
Output as a JSON string to an IntConsumer.
-
output
@Deprecated(message = "renamed to outputTo", replaceWith = @ReplaceWith(imports = {}, expression = "outputTo(out)")) Unit output(IntConsumer out)
Output as a JSON string to an IntConsumer.
-
coOutputTo
Unit coOutputTo(SuspendFunction1<Character, Unit> out)
Output as a JSON string to a CoOutput.
-
coOutput
@Deprecated(message = "renamed to coOutputTo", replaceWith = @ReplaceWith(imports = {}, expression = "coOutputTo(out)")) Unit coOutput(SuspendFunction1<Character, Unit> out)
Output as a JSON string to a CoOutput.
-
isIntegral
Boolean isIntegral()
Return
trueif the value is integral (has no fractional part, or the fractional part is zero).
-
isNegative
Boolean isNegative()
Return
trueif the value is negative.
-
isPositive
Boolean isPositive()
Return
trueif the value is positive.
-
isNotNegative
Boolean isNotNegative()
Return
trueif the value is not negative.
-
isNotPositive
Boolean isNotPositive()
Return
trueif the value is not positive.
-
toDecimal
BigDecimal toDecimal()
Convert the value to BigDecimal.
-
equals
Boolean equals(Object other)
Compare the value to another JSONNumber value. JSONNumber objects with different types but the same value are considered equal.
-
hashCode
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.
-
-
-
-