- All Known Subinterfaces:
Json<T>
- All Known Implementing Classes:
JsArray,JsBigDec,JsBigInt,JsBinary,JsBool,JsDouble,JsInstant,JsInt,JsLong,JsNothing,JsNull,JsNumber,JsObj,JsPrimitive,JsStr
Represents a json element of any type. Every json type implements this interface. This interface
implements two kind of methods:
- Classificatory methods, which starts with the prefix isXXX
- Accessory methods to convert the JsValue to the real implementation, which starts with the prefix asJsXXX
-
Method Summary
Modifier and TypeMethodDescriptiondefault JsValuereturns the specified default value if nothing or the same this objectdefault JsValuereturns the specified default value if null or the same this objectdefault booleanisArray()Returns true if this JsValue is a JsArraydefault booleanReturns true if this elem is a JsArray and satisfies the given predicatedefault booleanisBigDec()Returns true if this JsValue is a JsBigDecdefault booleanisBigDec(Predicate<BigDecimal> predicate) Returns true if this elem is a JsBigDec and satisfies the given predicatedefault booleanisBigInt()Returns true if this JsValue is a JsBigIntdefault booleanisBigInt(Predicate<BigInteger> predicate) Returns true if this elem is a JsBigInt and satisfies the given predicatedefault booleanisBinary()Returns true if this JsValue is a JsBinary or a JsString which value is an array ofdefault booleanisBool()Returns true if this JsValue is a JsBooldefault booleanReturns true if this element is a decimal number (JsDouble or JsBigDec)default booleanisDouble()Returns true if this JsValue is a JsDoubledefault booleanisDouble(DoublePredicate predicate) Returns true if this elem is a JsDouble and satisfies the given predicatedefault booleanisFalse()Returns true if this JsValue is a JsBool, and it's falsedefault booleanReturns true if this JsValue is a JsInstant or a JsString which value is a date formatted in ISO-8601default booleanReturns true if this elem is a JsInstant and satisfies the given predicatedefault booleanisInt()Returns true if this JsValue is a JsIntdefault booleanisInt(IntPredicate predicate) Returns true if this elem is a JsInt and satisfies the given predicatedefault booleanReturns true if this element is an integral number (JsInt or JsLong or JsBigInt)default booleanisJson()Returns true if this JsValue is a Json (JsObj or JsArray)default booleanReturns true if this elem is a Json and satisfies the given predicatedefault booleanisLong()Returns this JsValue as a JsLongdefault booleanisLong(LongPredicate predicate) Returns true if this elem is a JsLong and satisfies the given predicatedefault booleanReturns true if this element is JsNothingdefault booleanReturns true if this element is not JsNothingdefault booleanReturn true if this element is not nulldefault booleanReturns true if this element is not a numberdefault booleanisNull()Returns true if this element is nulldefault booleanisNumber()Returns true if this element is a numberdefault booleanisObj()Returns true if this JsValue is a JsObjdefault booleanReturns true if this elem is a JsObj and satisfies the given predicatedefault booleanReturns true if this JsValue is a not a Json (neither JsObj nor JsArray)default booleanisSameType(JsValue that) returns true if this elem and the given have the same typedefault booleanisStr()Returns true if this JsValue is a JsStrdefault booleanReturns true if this elem is a JsStr and satisfies the given predicatedefault booleanisTrue()Returns true if this JsValue is a JsBool, and it's truedefault JsArrayReturns this JsValue as a JsArraydefault JsBigDecReturns this JsValue as a JsBigDecdefault JsBigIntRetruns this JsValue as a JsBigIntdefault JsBinaryReturns this JsValue as a JsBinarydefault JsBooltoJsBool()Returns this JsValue as a JsBooldefault JsDoubleReturns this JsValue as a JsDoubledefault JsInstantReturns this JsValue as a JsInstantdefault JsInttoJsInt()Returns this JsValue as a JsIntdefault JsLongtoJsLong()Returns this JsValue as a JsLongdefault JsNumberReturns this JsValue as a JsStrdefault JsObjtoJsObj()Returns this JsValue as a JsObjdefault Json<?>toJson()Returns this JsValue as a Jsondefault JsStrtoJsStr()Returns this JsValue as a JsStr
-
Method Details
-
toJsBool
Returns this JsValue as a JsBool- Returns:
- this JsValue as a JsBool
- Throws:
UserError- if this JsValue is not a JsBool
-
toJsPrimitive
JsPrimitive toJsPrimitive() -
isBinary
default boolean isBinary()Returns true if this JsValue is a JsBinary or a JsString which value is an array of- Returns:
- true if this JsValue is a JsBinary or a JsString which value is an array of bytes encoded in base64
-
isInstant
default boolean isInstant()Returns true if this JsValue is a JsInstant or a JsString which value is a date formatted in ISO-8601- Returns:
- true if this JsValue is a JsInstant or a JsString which value is a date formatted in ISO-8601
-
isInstant
Returns true if this elem is a JsInstant and satisfies the given predicate- Parameters:
predicate- the given predicate- Returns:
- true if this JsValue is a JsInstant and satisfies the predicate
-
isBool
default boolean isBool()Returns true if this JsValue is a JsBool- Returns:
- true if this JsValue is a JsBool
-
isSameType
returns true if this elem and the given have the same type- Parameters:
that- the given elem- Returns:
- true if this JsValue and the given have the same type
-
isTrue
default boolean isTrue()Returns true if this JsValue is a JsBool, and it's true- Returns:
- true if this JsValue is a JsBool, and it's true
-
isFalse
default boolean isFalse()Returns true if this JsValue is a JsBool, and it's false- Returns:
- true if this JsValue is a JsBool, and it's false
-
isInt
Returns true if this elem is a JsInt and satisfies the given predicate- Parameters:
predicate- the given predicate- Returns:
- true if this JsValue is a JsInt and satisfies the predicate
-
isInt
default boolean isInt()Returns true if this JsValue is a JsInt- Returns:
- true if this JsValue is a JsInt
-
toJsInt
Returns this JsValue as a JsInt- Returns:
- this JsValue as a JsInt
- Throws:
UserError- if this JsValue is not a JsInt
-
toJsInstant
Returns this JsValue as a JsInstant- Returns:
- this JsValue as a JsInstant
- Throws:
UserError- if this JsValue is not a JsInt
-
toJsBinary
Returns this JsValue as a JsBinary- Returns:
- this JsValue as a JsBinary
- Throws:
UserError- if this JsValue is not a JsBinary
-
isDouble
Returns true if this elem is a JsDouble and satisfies the given predicate- Parameters:
predicate- the given predicate- Returns:
- true if this JsValue is a JsDouble and satisfies the predicate
-
isDouble
default boolean isDouble()Returns true if this JsValue is a JsDouble- Returns:
- true if this JsValue is a JsDouble
-
toJsDouble
Returns this JsValue as a JsDouble- Returns:
- this JsValue as a JsDouble
- Throws:
UserError- if this JsValue is not a JsDouble
-
isBigDec
Returns true if this elem is a JsBigDec and satisfies the given predicate- Parameters:
predicate- the given predicate- Returns:
- true if this JsValue is a JsBigDec and satisfies the predicate
-
isBigDec
default boolean isBigDec()Returns true if this JsValue is a JsBigDec- Returns:
- true if this JsValue is a JsBigDec
-
toJsBigDec
Returns this JsValue as a JsBigDec- Returns:
- this JsValue as a JsBigDec
- Throws:
UserError- if this JsValue is not a JsBigDec or a JsDouble
-
isLong
Returns true if this elem is a JsLong and satisfies the given predicate- Parameters:
predicate- the given predicate- Returns:
- true if this JsValue is a JsLong and satisfies the predicate
-
isLong
default boolean isLong()Returns this JsValue as a JsLong- Returns:
- true if this JsValue is a JsLong
-
toJsLong
Returns this JsValue as a JsLong- Returns:
- this JsValue as a JsLong
- Throws:
UserError- if this JsValue is not a JsLong or a JsInt
-
isPrimitive
default boolean isPrimitive()Returns true if this JsValue is a not a Json (neither JsObj nor JsArray)- Returns:
- true if this JsValue is a not a Json (neither JsObj nor JsArray)
-
isJson
default boolean isJson()Returns true if this JsValue is a Json (JsObj or JsArray)- Returns:
- true if this JsValue is a Json (JsObj or JsArray)
-
isObj
default boolean isObj()Returns true if this JsValue is a JsObj- Returns:
- true if this JsValue is a JsObj
-
isArray
default boolean isArray()Returns true if this JsValue is a JsArray- Returns:
- true if this JsValue is a JsArray
-
isJson
Returns true if this elem is a Json and satisfies the given predicate- Parameters:
predicate- the given predicate- Returns:
- true if this JsValue is a Json and satisfies the predicate
-
toJson
Returns this JsValue as a Json- Returns:
- this JsValue as a Json
- Throws:
UserError- if this JsValue is not a JsObj or a JsArray
-
toJsObj
Returns this JsValue as a JsObj- Returns:
- this JsValue as a JsObj
- Throws:
UserError- if this JsValue is not a JsObj
-
toJsArray
Returns this JsValue as a JsArray- Returns:
- this JsValue as a JsArray
- Throws:
UserError- if this JsValue is not a JsArray
-
isObj
Returns true if this elem is a JsObj and satisfies the given predicate- Parameters:
predicate- the given predicate- Returns:
- true if this JsValue is a JsObj and satisfies the predicate
-
isArray
Returns true if this elem is a JsArray and satisfies the given predicate- Parameters:
predicate- the given predicate- Returns:
- true if this JsValue is a JsArray and satisfies the predicate
-
toJsNumber
Returns this JsValue as a JsStr- Returns:
- this JsValue as a JsStr
- Throws:
UserError- if this JsValue is not a JsStr
-
isBigInt
Returns true if this elem is a JsBigInt and satisfies the given predicate- Parameters:
predicate- the given predicate- Returns:
- true if this JsValue is a JsBigInt and satisfies the predicate
-
isBigInt
default boolean isBigInt()Returns true if this JsValue is a JsBigInt- Returns:
- true if this JsValue is a JsBigInt
-
toJsBigInt
Retruns this JsValue as a JsBigInt- Returns:
- this JsValue as a JsBigInt
- Throws:
UserError- if this JsValue is not a JsBigInt or JsLong or JsInt
-
isStr
Returns true if this elem is a JsStr and satisfies the given predicate- Parameters:
predicate- the given predicate- Returns:
- true if this JsValue is a JsStr and satisfies the predicate
-
isStr
default boolean isStr()Returns true if this JsValue is a JsStr- Returns:
- true if this JsValue is a JsStr
-
toJsStr
Returns this JsValue as a JsStr- Returns:
- this JsValue as a JsStr
- Throws:
UserError- if this JsValue is not a JsStr
-
isIntegral
default boolean isIntegral()Returns true if this element is an integral number (JsInt or JsLong or JsBigInt)- Returns:
- true if this element is an integral number (JsInt or JsLong or JsBigInt)
-
isDecimal
default boolean isDecimal()Returns true if this element is a decimal number (JsDouble or JsBigDec)- Returns:
- true if this element is a decimal number (JsDouble or JsBigDec)
-
isNotNull
default boolean isNotNull()Return true if this element is not null- Returns:
- true if this element is not null
-
isNull
default boolean isNull()Returns true if this element is null- Returns:
- true if this element is null
-
isNotNothing
default boolean isNotNothing()Returns true if this element is not JsNothing- Returns:
- true if this element is not JsNothing
-
isNothing
default boolean isNothing()Returns true if this element is JsNothing- Returns:
- true if this element is JsNothing
-
isNotNumber
default boolean isNotNumber()Returns true if this element is not a number- Returns:
- true if this element is not a number
-
isNumber
default boolean isNumber()Returns true if this element is a number- Returns:
- true if this element is a number
-
ifNull
returns the specified default value if null or the same this object- Parameters:
value- the default value- Returns:
- a json value
-
ifNothing
returns the specified default value if nothing or the same this object- Parameters:
value- the default value- Returns:
- a json value
-