Package jsonvalues
Interface JsElem
-
- All Known Implementing Classes:
JsBigDec
,JsBigInt
,JsBool
,JsDouble
,JsInt
,JsLong
,JsNothing
,JsNull
,JsStr
public interface JsElem
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 JsElem to the real implementation, which starts with the prefix asJsXXX
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default JsArray
asJsArray()
default JsBigDec
asJsBigDec()
default JsBigInt
asJsBigInt()
default JsBool
asJsBool()
default JsDouble
asJsDouble()
default JsInt
asJsInt()
default JsLong
asJsLong()
default JsObj
asJsObj()
default Json<?>
asJson()
default JsStr
asJsStr()
boolean
isArray()
default boolean
isArray(Predicate<JsArray> predicate)
Returns true if this elem is a JsArray and satisfies the given predicateboolean
isBigDec()
default boolean
isBigDec(Predicate<BigDecimal> predicate)
Returns true if this elem is a JsBigDec and satisfies the given predicateboolean
isBigInt()
default boolean
isBigInt(Predicate<BigInteger> predicate)
Returns true if this elem is a JsBigInt and satisfies the given predicateboolean
isBool()
default boolean
isDecimal()
boolean
isDouble()
default boolean
isDouble(DoublePredicate predicate)
Returns true if this elem is a JsDouble and satisfies the given predicateboolean
isFalse()
default boolean
isInstant()
default boolean
isInstant(Predicate<Instant> predicate)
Returns true if this elem is a JsStr that contains an Instant and satisfies the given predicateboolean
isInt()
default boolean
isInt(IntPredicate predicate)
Returns true if this elem is a JsInt and satisfies the given predicatedefault boolean
isIntegral()
default boolean
isJson()
default boolean
isJson(Predicate<Json<?>> predicate)
Returns true if this elem is a Json and satisfies the given predicatedefault boolean
isLocalDate(DateTimeFormatter formatter)
return true if this JsElem is a JsStr that contains a local date that can be parsed with the given formatterdefault boolean
isLocalDate(DateTimeFormatter formatter, Predicate<LocalDate> predicate)
return true if this JsElem is a JsStr that contains a local date that can be parsed with the given formatter and satisfies the given predicatedefault boolean
isLocalDateTime(DateTimeFormatter formatter)
return true if this JsElem is a JsStr that contains a local date-time that can be parsed with the given formatterdefault boolean
isLocalDateTime(DateTimeFormatter formatter, Predicate<LocalDateTime> predicate)
return true if this JsElem is a JsStr that contains a local date-time that can be parsed with the given formatter and satisfies the given predicateboolean
isLong()
default boolean
isLong(LongPredicate predicate)
Returns true if this elem is a JsLong and satisfies the given predicateboolean
isNothing()
default boolean
isNotJson()
default boolean
isNotNothing()
default boolean
isNotNull()
default boolean
isNotNumber()
boolean
isNull()
default boolean
isNumber()
boolean
isObj()
default boolean
isObj(Predicate<JsObj> predicate)
Returns true if this elem is a JsObj and satisfies the given predicatedefault boolean
isSameType(JsElem that)
returns true if this elem and the given have the same typeboolean
isStr()
default boolean
isStr(Predicate<String> predicate)
Returns true if this elem is a JsStr and satisfies the given predicateboolean
isTrue()
-
-
-
Method Detail
-
asJsBool
default JsBool asJsBool()
- Returns:
- this JsElem as a JsBool
- Throws:
UnsupportedOperationException
- if this JsElem is not a JsBool
-
isBool
boolean isBool()
- Returns:
- true if this JsElem is a JsBool
-
isSameType
default boolean isSameType(JsElem that)
returns true if this elem and the given have the same type- Parameters:
that
- the given elem- Returns:
- true if this JsElem and the given have the same type
-
isTrue
boolean isTrue()
- Returns:
- true if this JsElem is a JsBool and it's true
-
isFalse
boolean isFalse()
- Returns:
- true if this JsElem is a JsBool and it's false
-
asJsInt
default JsInt asJsInt()
- Returns:
- this JsElem as a JsInt
- Throws:
UnsupportedOperationException
- if this JsElem is not a JsInt
-
isInt
boolean isInt()
- Returns:
- true if this JsElem is a JsInt
-
isInt
default boolean isInt(IntPredicate predicate)
Returns true if this elem is a JsInt and satisfies the given predicate- Parameters:
predicate
- the given predicate- Returns:
- true if this JsElem is a JsInt and satisfies the predicate
-
asJsDouble
default JsDouble asJsDouble()
- Returns:
- this JsElem as a JsDouble
- Throws:
UnsupportedOperationException
- if this JsElem is not a JsDouble
-
isDouble
boolean isDouble()
- Returns:
- true if this JsElem is a JsDouble
-
isDouble
default boolean isDouble(DoublePredicate predicate)
Returns true if this elem is a JsDouble and satisfies the given predicate- Parameters:
predicate
- the given predicate- Returns:
- true if this JsElem is a JsDouble and satisfies the predicate
-
asJsBigDec
default JsBigDec asJsBigDec()
- Returns:
- this JsElem as a JsBigDec
- Throws:
UnsupportedOperationException
- if this JsElem is not a JsBigDec or a JsDouble
-
isBigDec
boolean isBigDec()
- Returns:
- true if this JsElem is a JsBigDec
-
isBigDec
default boolean isBigDec(Predicate<BigDecimal> predicate)
Returns true if this elem is a JsBigDec and satisfies the given predicate- Parameters:
predicate
- the given predicate- Returns:
- true if this JsElem is a JsBigDec and satisfies the predicate
-
asJsLong
default JsLong asJsLong()
- Returns:
- this JsElem as a JsLong
- Throws:
UnsupportedOperationException
- if this JsElem is not a JsLong or a JsInt
-
isLong
boolean isLong()
- Returns:
- true if this JsElem is a JsLong
-
isLong
default boolean isLong(LongPredicate predicate)
Returns true if this elem is a JsLong and satisfies the given predicate- Parameters:
predicate
- the given predicate- Returns:
- true if this JsElem is a JsLong and satisfies the predicate
-
asJson
default Json<?> asJson()
- Returns:
- this JsElem as a Json
- Throws:
UnsupportedOperationException
- if this JsElem is not a JsObj or a JsArray
-
isJson
default boolean isJson()
- Returns:
- true if this JsElem is a Json (JsObj or JsArray)
-
isNotJson
default boolean isNotJson()
- Returns:
- true if this JsElem is a not a Json (neither JsObj nor JsArray)
-
isJson
default boolean isJson(Predicate<Json<?>> predicate)
Returns true if this elem is a Json and satisfies the given predicate- Parameters:
predicate
- the given predicate- Returns:
- true if this JsElem is a Json and satisfies the predicate
-
asJsObj
default JsObj asJsObj()
- Returns:
- this JsElem as a JsObj
- Throws:
UnsupportedOperationException
- if this JsElem is not a JsObj
-
isObj
boolean isObj()
- Returns:
- true if this JsElem is a JsObj
-
isObj
default boolean isObj(Predicate<JsObj> predicate)
Returns true if this elem is a JsObj and satisfies the given predicate- Parameters:
predicate
- the given predicate- Returns:
- true if this JsElem is a JsObj and satisfies the predicate
-
asJsArray
default JsArray asJsArray()
- Returns:
- this JsElem as a JsArray
- Throws:
UnsupportedOperationException
- if this JsElem is not a JsArray
-
isArray
boolean isArray()
- Returns:
- true if this JsElem is a JsArray
-
isArray
default boolean isArray(Predicate<JsArray> predicate)
Returns true if this elem is a JsArray and satisfies the given predicate- Parameters:
predicate
- the given predicate- Returns:
- true if this JsElem is a JsArray and satisfies the predicate
-
asJsStr
default JsStr asJsStr()
- Returns:
- this JsElem as a JsStr
- Throws:
UnsupportedOperationException
- if this JsElem is not a JsStr
-
isStr
boolean isStr()
- Returns:
- true if this JsElem is a JsStr
-
isStr
default boolean isStr(Predicate<String> predicate)
Returns true if this elem is a JsStr and satisfies the given predicate- Parameters:
predicate
- the given predicate- Returns:
- true if this JsElem is a JsStr and satisfies the predicate
-
asJsBigInt
default JsBigInt asJsBigInt()
- Returns:
- this JsElem as a JsBigInt
- Throws:
UnsupportedOperationException
- if this JsElem is not a JsBigInt or JsLong or JsInt
-
isBigInt
boolean isBigInt()
- Returns:
- true if this JsElem is a JsBigInt
-
isBigInt
default boolean isBigInt(Predicate<BigInteger> predicate)
Returns true if this elem is a JsBigInt and satisfies the given predicate- Parameters:
predicate
- the given predicate- Returns:
- true if this JsElem is a JsBigInt and satisfies the predicate
-
isInstant
default boolean isInstant()
- Returns:
- true if this JsElem is a JsStr that contains an instant in the format
DateTimeFormatter.ISO_INSTANT
-
isInstant
default boolean isInstant(Predicate<Instant> predicate)
Returns true if this elem is a JsStr that contains an Instant and satisfies the given predicate- Parameters:
predicate
- the given predicate- Returns:
- true if this JsElem is a JsStr that contains an Instant and satisfies the predicate
-
isLocalDate
default boolean isLocalDate(DateTimeFormatter formatter)
return true if this JsElem is a JsStr that contains a local date that can be parsed with the given formatter- Parameters:
formatter
- the given formatter- Returns:
- true if this JsElem is a JsStr that contains a local date that can be parsed with the given formatter
-
isLocalDate
default boolean isLocalDate(DateTimeFormatter formatter, Predicate<LocalDate> predicate)
return true if this JsElem is a JsStr that contains a local date that can be parsed with the given formatter and satisfies the given predicate- Parameters:
formatter
- the given formatterpredicate
- the given predicate- Returns:
- true if this JsElem is a JsStr that contains a local date that can be parsed with the formatter and satisfies the predicate
-
isLocalDateTime
default boolean isLocalDateTime(DateTimeFormatter formatter)
return true if this JsElem is a JsStr that contains a local date-time that can be parsed with the given formatter- Parameters:
formatter
- the given formatter- Returns:
- true if this JsElem is a JsStr that contains a local date-time that can be parsed with the given formatter
-
isLocalDateTime
default boolean isLocalDateTime(DateTimeFormatter formatter, Predicate<LocalDateTime> predicate)
return true if this JsElem is a JsStr that contains a local date-time that can be parsed with the given formatter and satisfies the given predicate- Parameters:
formatter
- the given formatterpredicate
- the given predicate- Returns:
- true if this JsElem is a JsStr that contains a local date-time that can be parsed with the formatter and satisfies the predicate
-
isIntegral
default boolean isIntegral()
- Returns:
- true if this element is an integral number (JsInt or JsLong or JsBigInt)
-
isDecimal
default boolean isDecimal()
- Returns:
- true if this element is an decimal number (JsDouble or JsBigDec)
-
isNull
boolean isNull()
- Returns:
- true if this element is null
-
isNothing
boolean isNothing()
- Returns:
- true if this element is JsNothing
-
isNotNull
default boolean isNotNull()
- Returns:
- true if this element is not null
-
isNotNothing
default boolean isNotNothing()
- Returns:
- true if this element is not JsNothing
-
isNumber
default boolean isNumber()
- Returns:
- true if this element is a number
-
isNotNumber
default boolean isNotNumber()
- Returns:
- true if this element is not a number
-
-