public interface JsValue
1. Classificatory methods, which start with the prefix isXXX. 2. Accessory methods to convert the JsValue to the real implementation, which start with the prefix toJsXXX.
Modifier and Type | Method and Description |
---|---|
default JsValue |
ifNothing(JsValue value)
Returns the specified default value if nothing or the same this object.
|
default JsValue |
ifNull(JsValue value)
Returns the specified default value if null or the same this object.
|
default boolean |
isArray()
Returns true if this JsValue is a JsArray.
|
default boolean |
isArray(Predicate<JsArray> predicate)
Returns true if this element is a JsArray and satisfies the given predicate.
|
default boolean |
isBigDec()
Returns true if this JsValue is a JsBigDec.
|
default boolean |
isBigDec(Predicate<BigDecimal> predicate)
Returns true if this element is a JsBigDec and satisfies the given predicate.
|
default boolean |
isBigInt()
Returns true if this JsValue is a JsBigInt.
|
default boolean |
isBigInt(Predicate<BigInteger> predicate)
Returns true if this element is a JsBigInt and satisfies the given predicate.
|
default boolean |
isBinary()
Returns true if this JsValue is a JsBinary or a JsString with a value that is an array of bytes encoded in
base64.
|
default boolean |
isBool()
Returns true if this JsValue is a JsBool.
|
default boolean |
isDecimal()
Returns true if this element is a decimal number (JsDouble or JsBigDec).
|
default boolean |
isDouble()
Returns true if this JsValue is a JsDouble.
|
default boolean |
isDouble(DoublePredicate predicate)
Returns true if this element is a JsDouble and satisfies the given predicate.
|
default boolean |
isFalse()
Returns true if this JsValue is a JsBool and its value is false.
|
default boolean |
isInstant()
Returns true if this JsValue is a JsInstant or a JsString with a value that is a date formatted in ISO-8601.
|
default boolean |
isInstant(Predicate<Instant> predicate)
Returns true if this element is a JsInstant and satisfies the given predicate.
|
default boolean |
isInt()
Returns true if this JsValue is a JsInt.
|
default boolean |
isInt(IntPredicate predicate)
Returns true if this element is a JsInt and satisfies the given predicate.
|
default boolean |
isIntegral()
Returns true if this element is an integral number (JsInt, JsLong, or JsBigInt).
|
default boolean |
isJson()
Returns true if this JsValue is a Json (JsObj or JsArray).
|
default boolean |
isJson(Predicate<Json<?>> predicate)
Returns true if this element is a Json and satisfies the given predicate.
|
default boolean |
isLong()
Returns this JsValue as a JsLong.
|
default boolean |
isLong(LongPredicate predicate)
Returns true if this element is a JsLong and satisfies the given predicate.
|
default boolean |
isNothing()
Returns true if this element is JsNothing.
|
default boolean |
isNotNothing()
Returns true if this element is not JsNothing.
|
default boolean |
isNotNull()
Return true if this element is not null.
|
default boolean |
isNotNumber()
Returns true if this element is not a number.
|
default boolean |
isNull()
Returns true if this element is null.
|
default boolean |
isNumber()
Returns true if this element is a number.
|
default boolean |
isObj()
Returns true if this JsValue is a JsObj.
|
default boolean |
isObj(Predicate<JsObj> predicate)
Returns true if this element is a JsObj and satisfies the given predicate.
|
default boolean |
isPrimitive()
Returns true if this JsValue is not a Json (neither JsObj nor JsArray).
|
default boolean |
isSameType(JsValue that)
Returns true if this JsValue is of the same type as the given JsValue.
|
default boolean |
isStr()
Returns true if this JsValue is a JsStr.
|
default boolean |
isStr(Predicate<String> predicate)
Returns true if this element is a JsStr and satisfies the given predicate.
|
default boolean |
isTrue()
Returns true if this JsValue is a JsBool and its value is true.
|
default JsArray |
toJsArray()
Returns this JsValue as a JsArray.
|
default JsBigDec |
toJsBigDec()
Returns this JsValue as a JsBigDec.
|
default JsBigInt |
toJsBigInt()
Returns this JsValue as a JsBigInt.
|
default JsBinary |
toJsBinary()
Returns this JsValue as a JsBinary.
|
default JsBool |
toJsBool()
Returns this JsValue as a JsBool.
|
default JsDouble |
toJsDouble()
Returns this JsValue as a JsDouble.
|
default JsInstant |
toJsInstant()
Returns this JsValue as a JsInstant.
|
default JsInt |
toJsInt()
Returns this JsValue as a JsInt.
|
default JsLong |
toJsLong()
Returns this JsValue as a JsLong.
|
default JsNumber |
toJsNumber()
Returns this JsValue as a JsStr.
|
default JsObj |
toJsObj()
Returns this JsValue as a JsObj.
|
default Json<?> |
toJson()
Returns this JsValue as a Json.
|
JsPrimitive |
toJsPrimitive()
Returns this JsValue as a JsPrimitive.
|
default JsStr |
toJsStr()
Returns this JsValue as a JsStr.
|
default JsBool toJsBool()
UserError
- if this JsValue is not a JsBool or cannot be converted to JsBool.JsPrimitive toJsPrimitive()
UserError
- if this JsValue is a Json container (object or array).default boolean isBinary()
default boolean isInstant()
default boolean isInstant(Predicate<Instant> predicate)
predicate
- The given predicate.default boolean isBool()
default boolean isSameType(JsValue that)
that
- The given JsValue.default boolean isTrue()
default boolean isFalse()
default boolean isInt(IntPredicate predicate)
predicate
- The given predicate.default boolean isInt()
default JsInt toJsInt()
UserError
- if this JsValue is not a JsInt or cannot be converted to JsInt.default JsInstant toJsInstant()
UserError
- if this JsValue is not a JsInstant or cannot be converted to JsInstant, e.g., if it's not a
JsInstant or a JsString with a date formatted in ISO-8601.default JsBinary toJsBinary()
UserError
- if this JsValue is not a JsBinary or cannot be converted to JsBinary, e.g., if it's not a
JsBinary or a JsString with a value encoded in base64.default boolean isDouble(DoublePredicate predicate)
predicate
- The given predicate.default boolean isDouble()
default JsDouble toJsDouble()
UserError
- if this JsValue is not a JsDouble or cannot be converted to JsDouble.default boolean isBigDec(Predicate<BigDecimal> predicate)
predicate
- The given predicate.default boolean isBigDec()
default JsBigDec toJsBigDec()
UserError
- if this JsValue is not a JsBigDec or cannot be converted to JsBigDec.default boolean isLong(LongPredicate predicate)
predicate
- The given predicate.default boolean isLong()
UserError
- if this JsValue is not a JsLong, JsInt, or cannot be converted to JsLong.default JsLong toJsLong()
UserError
- if this JsValue is not a JsLong, JsInt, or cannot be converted to JsLong.default boolean isPrimitive()
default boolean isJson()
default boolean isObj()
default boolean isArray()
default boolean isJson(Predicate<Json<?>> predicate)
predicate
- The given predicate.default Json<?> toJson()
UserError
- if this JsValue is not a JsObj or JsArray or cannot be converted to Json.default JsObj toJsObj()
UserError
- if this JsValue is not a JsObj or cannot be converted to JsObj.default JsArray toJsArray()
UserError
- if this JsValue is not a JsArray or cannot be converted to JsArray.default boolean isObj(Predicate<JsObj> predicate)
predicate
- The given predicate.default boolean isArray(Predicate<JsArray> predicate)
predicate
- The given predicate.default JsNumber toJsNumber()
UserError
- if this JsValue is not a JsStr or cannot be converted to JsStr.default boolean isBigInt(Predicate<BigInteger> predicate)
predicate
- The given predicate.default boolean isBigInt()
default JsBigInt toJsBigInt()
UserError
- if this JsValue is not a JsBigInt, JsLong, JsInt, or cannot be converted to JsBigInt.default boolean isStr(Predicate<String> predicate)
predicate
- The given predicate.default boolean isStr()
default JsStr toJsStr()
UserError
- if this JsValue is not a JsStr or cannot be converted to JsStr.default boolean isIntegral()
default boolean isDecimal()
default boolean isNotNull()
default boolean isNull()
default boolean isNotNothing()
default boolean isNothing()
default boolean isNotNumber()
default boolean isNumber()
default JsValue ifNull(JsValue value)
value
- The default value.Copyright © 2023. All rights reserved.