public.javadoc.org.spincast.core.json.JsonObjectArrayBase.html Maven / Gradle / Ivy
Show all versions of spincast-website Show documentation
JsonObjectArrayBase (org.spincast:spincast-framework 1.0.0 API)
org.spincast.core.json
Class JsonObjectArrayBase
- java.lang.Object
-
- org.spincast.core.json.JsonObjectArrayBase
-
- All Implemented Interfaces:
- JsonObjectOrArray
- Direct Known Subclasses:
- JsonArrayDefault, JsonObjectDefault
public abstract class JsonObjectArrayBase
extends Object
implements JsonObjectOrArray
Base class for both JsonObject and JsonArray.
-
-
Nested Class Summary
Nested Classes
Modifier and Type
Class and Description
static class
JsonObjectArrayBase.JsonPathCachingItem
-
Field Summary
Fields
Modifier and Type
Field and Description
protected Object
defaultElementValidator
protected org.slf4j.Logger
logger
-
Constructor Summary
Constructors
Constructor and Description
JsonObjectArrayBase(boolean mutable,
JsonManager jsonManager,
SpincastUtils spincastUtils,
ObjectConverter objectConverter)
Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods
Modifier and Type
Method and Description
protected Object
clone()
abstract JsonObjectOrArray
clone(boolean mutable)
Clone the object.
boolean
contains(String jsonPath)
Does the object contain an element at
the JsonPath
position (even if
null
)?
protected <T> T
getArrayFirst(String jsonPath,
boolean parseJsonPath,
boolean hasdefaultElement,
T defaultElement,
JsonObjectDefault.IFirstElementGetter<T> firstElementGetter)
BigDecimal
getArrayFirstBigDecimal(String key)
Gets the first value (as BigDecimal) of a JsonArray
property
of the object, using the JsonPath
to find the array.
BigDecimal
getArrayFirstBigDecimal(String key,
BigDecimal defaultElement)
Gets the first value (as BigDecimal) of a JsonArray
property
of the object, using the JsonPath
to find the array.
protected BigDecimal
getArrayFirstBigDecimal(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
BigDecimal defaultElement)
BigDecimal
getArrayFirstBigDecimalNoKeyParsing(String key)
BigDecimal
getArrayFirstBigDecimalNoKeyParsing(String key,
BigDecimal defaultElement)
Boolean
getArrayFirstBoolean(String key)
Gets the first value (as Boolean) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Boolean
getArrayFirstBoolean(String key,
Boolean defaultElement)
Gets the first value (as Boolean) of a JsonArray
property
of the object, using the JsonPath
to find the array.
protected Boolean
getArrayFirstBoolean(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
Boolean defaultElement)
Boolean
getArrayFirstBooleanNoKeyParsing(String key)
Boolean
getArrayFirstBooleanNoKeyParsing(String key,
Boolean defaultElement)
byte[]
getArrayFirstBytesFromBase64String(String key)
Gets the first value (as byte[]) of a JsonArray
property
of the object, using the JsonPath
to find the array.
protected byte[]
getArrayFirstBytesFromBase64String(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
byte[] defaultElement)
byte[]
getArrayFirstBytesFromBase64String(String key,
byte[] defaultElement)
Gets the first value (as byte[]) of a JsonArray
property
of the object, using the JsonPath
to find the array.
byte[]
getArrayFirstBytesFromBase64StringNoKeyParsing(String key)
byte[]
getArrayFirstBytesFromBase64StringNoKeyParsing(String key,
byte[] defaultElement)
Date
getArrayFirstDate(String key)
Gets the first value (as Date) of a JsonArray
property
of the object, using the JsonPath
to find the array.
protected Date
getArrayFirstDate(String jsonPath,
boolean parseJsonPath,
boolean hasdefaultElement,
Date defaultElement)
Date
getArrayFirstDate(String key,
Date defaultElement)
Gets the first value (as Date) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Date
getArrayFirstDateNoKeyParsing(String key)
Date
getArrayFirstDateNoKeyParsing(String key,
Date defaultElement)
Double
getArrayFirstDouble(String key)
Gets the first value (as Double) of a JsonArray
property
of the object, using the JsonPath
to find the array.
protected Double
getArrayFirstDouble(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
Double defaultElement)
Double
getArrayFirstDouble(String key,
Double defaultElement)
Gets the first value (as Double) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Double
getArrayFirstDoubleNoKeyParsing(String key)
Double
getArrayFirstDoubleNoKeyParsing(String key,
Double defaultElement)
Float
getArrayFirstFloat(String key)
Gets the first value (as Float) of a JsonArray
property
of the object, using the JsonPath
to find the array.
protected Float
getArrayFirstFloat(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
Float defaultElement)
Float
getArrayFirstFloat(String key,
Float defaultElement)
Gets the first value (as Float) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Float
getArrayFirstFloatNoKeyParsing(String key)
Float
getArrayFirstFloatNoKeyParsing(String key,
Float defaultElement)
Instant
getArrayFirstInstant(String key)
Gets the first value (as Instant) of a JsonArray
property
of the object, using the JsonPath
to find the array.
protected Instant
getArrayFirstInstant(String jsonPath,
boolean parseJsonPath,
boolean hasdefaultElement,
Instant defaultElement)
Instant
getArrayFirstInstant(String key,
Instant defaultElement)
Gets the first value (as Instant) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Instant
getArrayFirstInstantNoKeyParsing(String key)
Instant
getArrayFirstInstantNoKeyParsing(String key,
Instant defaultElement)
Integer
getArrayFirstInteger(String key)
Gets the first value (as Integer) of a JsonArray
property
of the object, using the JsonPath
to find the array.
protected Integer
getArrayFirstInteger(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
Integer defaultElement)
Integer
getArrayFirstInteger(String key,
Integer defaultElement)
Gets the first value (as Integer) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Integer
getArrayFirstIntegerNoKeyParsing(String key)
Integer
getArrayFirstIntegerNoKeyParsing(String key,
Integer defaultElement)
JsonArray
getArrayFirstJsonArray(String key)
Gets the first value (as JsonArray) of a JsonArray
property
of the object, using the JsonPath
to find the array.
protected JsonArray
getArrayFirstJsonArray(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
JsonArray defaultElement)
JsonArray
getArrayFirstJsonArray(String key,
JsonArray defaultElement)
Gets the first value (as JsonArray) of a JsonArray
property
of the object, using the JsonPath
to find the array.
JsonArray
getArrayFirstJsonArrayNoKeyParsing(String key)
JsonArray
getArrayFirstJsonArrayNoKeyParsing(String key,
JsonArray defaultElement)
JsonObject
getArrayFirstJsonObject(String key)
Gets the first value (as JsonObject) of a JsonArray
property
of the object, using the JsonPath
to find the array.
protected JsonObject
getArrayFirstJsonObject(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
JsonObject defaultElement)
JsonObject
getArrayFirstJsonObject(String key,
JsonObject defaultElement)
Gets the first value (as JsonObject) of a JsonArray
property
of the object, using the JsonPath
to find the array.
JsonObject
getArrayFirstJsonObjectNoKeyParsing(String key)
JsonObject
getArrayFirstJsonObjectNoKeyParsing(String key,
JsonObject defaultElement)
Long
getArrayFirstLong(String key)
Gets the first value (as Long) of a JsonArray
property
of the object, using the JsonPath
to find the array.
protected Long
getArrayFirstLong(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
Long defaultElement)
Long
getArrayFirstLong(String key,
Long defaultElement)
Gets the first value (as Long) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Long
getArrayFirstLongNoKeyParsing(String key)
Long
getArrayFirstLongNoKeyParsing(String key,
Long defaultElement)
String
getArrayFirstString(String key)
Gets the first value (as String) of a JsonArray
property
of the object, using the JsonPath
to find the array.
protected String
getArrayFirstString(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
String defaultElement)
String
getArrayFirstString(String key,
String defaultElement)
Gets the first value (as String) of a JsonArray
property
of the object, using the JsonPath
to find the array.
String
getArrayFirstStringNoKeyParsing(String key)
String
getArrayFirstStringNoKeyParsing(String key,
String defaultElement)
BigDecimal
getBigDecimal(String jsonPath)
Gets an element as BigDecimal
using the
specified JsonPath
.
BigDecimal
getBigDecimal(String jsonPath,
BigDecimal defaultElement)
Gets an element as BigDecimal
using the
specified JsonPath
.
protected BigDecimal
getBigDecimal(String jsonPath,
boolean hasdefaultElement,
BigDecimal defaultElement,
boolean parseJsonPath)
protected BigDecimal
getBigDecimalElement(String jsonPath,
boolean hasdefaultElement,
BigDecimal defaultElement)
protected BigDecimal
getBigDecimalFromObject(Object object)
BigDecimal
getBigDecimalNoKeyParsing(String jsonPath)
BigDecimal
getBigDecimalNoKeyParsing(String jsonPath,
BigDecimal defaultElement)
Boolean
getBoolean(String jsonPath)
Gets an element as Boolean
using the
specified JsonPath
.
Boolean
getBoolean(String jsonPath,
Boolean defaultElement)
Gets an element as Boolean
using the
specified JsonPath
.
protected Boolean
getBoolean(String jsonPath,
boolean hasdefaultElement,
Boolean defaultElement,
boolean parseJsonPath)
protected Boolean
getBooleanElement(String jsonPath,
boolean hasdefaultElement,
Boolean defaultElement)
protected Boolean
getBooleanFromObject(Object object)
Boolean
getBooleanNoKeyParsing(String jsonPath)
Boolean
getBooleanNoKeyParsing(String jsonPath,
Boolean defaultElement)
byte[]
getBytesFromBase64String(String jsonPath)
Gets a byte array, from a base 64 encoded element using the
specified JsonPath
.
protected byte[]
getBytesFromBase64String(String jsonPath,
boolean hasdefaultElement,
byte[] defaultElement,
boolean parseJsonPath)
byte[]
getBytesFromBase64String(String jsonPath,
byte[] defaultElement)
Gets a byte array, from a base 64 encoded element using the
specified JsonPath
.
protected byte[]
getBytesFromBase64StringElement(String jsonPath,
boolean hasdefaultElement,
byte[] defaultElement)
byte[]
getBytesFromBase64StringNoKeyParsing(String jsonPath)
byte[]
getBytesFromBase64StringNoKeyParsing(String jsonPath,
byte[] defaultElement)
protected byte[]
getBytesFromBase64StringValueFromObject(Object object)
Date
getDate(String jsonPath)
Gets a UTC timezoned date from a ISO 8601
date string element using the
specified JsonPath
.
protected Date
getDate(String jsonPath,
boolean hasdefaultElement,
Date defaultElement,
boolean parseJsonPath)
Date
getDate(String jsonPath,
Date defaultElement)
Gets a UTC timezoned date from a ISO 8601
date string element using the
specified JsonPath
.
protected Date
getDateElement(String jsonPath,
boolean hasdefaultElement,
Date defaultElement)
protected Date
getDateFromObject(Object object)
Date
getDateNoKeyParsing(String jsonPath)
Date
getDateNoKeyParsing(String jsonPath,
Date defaultElement)
protected Object
getdefaultElementValidator()
Double
getDouble(String jsonPath)
Gets an element as Double
using the
specified JsonPath
.
protected Double
getDouble(String jsonPath,
boolean hasdefaultElement,
Double defaultElement,
boolean parseJsonPath)
Double
getDouble(String jsonPath,
Double defaultElement)
Gets an element as Double
using the
specified JsonPath
.
protected Double
getDoubleElement(String jsonPath,
boolean hasdefaultElement,
Double defaultElement)
protected Double
getDoubleFromObject(Object object)
Double
getDoubleNoKeyParsing(String jsonPath)
Double
getDoubleNoKeyParsing(String jsonPath,
Double defaultElement)
protected Object
getElement(String key,
boolean hasdefaultElement,
Object defaultElement,
boolean parseJsonPath)
Gets the element at this key/jsonPath/index.
protected abstract Object
getElementNoKeyParsing(String key,
boolean hasdefaultElement,
Object defaultElement)
Gets the element at this key/index, without
key parsing.
Float
getFloat(String jsonPath)
Gets an element as Float
using the
specified JsonPath
.
protected Float
getFloat(String jsonPath,
boolean hasdefaultElement,
Float defaultElement,
boolean parseJsonPath)
Float
getFloat(String jsonPath,
Float defaultElement)
Gets an element as Float
using the
specified JsonPath
.
protected Float
getFloatElement(String jsonPath,
boolean hasdefaultElement,
Float defaultElement)
protected Float
getFloatFromObject(Object object)
Float
getFloatNoKeyParsing(String jsonPath)
Float
getFloatNoKeyParsing(String jsonPath,
Float defaultElement)
Instant
getInstant(String jsonPath)
Gets an Instant from a ISO 8601
date string element using the
specified JsonPath
.
protected Instant
getInstant(String jsonPath,
boolean hasdefaultElement,
Instant defaultElement,
boolean parseJsonPath)
Instant
getInstant(String jsonPath,
Instant defaultElement)
Gets an Instant from a ISO 8601
date string element using the
specified JsonPath
.
protected Instant
getInstantElement(String jsonPath,
boolean hasdefaultElement,
Instant defaultElement)
protected Instant
getInstantFromObject(Object object)
Instant
getInstantNoKeyParsing(String jsonPath)
Instant
getInstantNoKeyParsing(String jsonPath,
Instant defaultElement)
Integer
getInteger(String jsonPath)
Gets an element as Integer
using the
specified JsonPath
.
protected Integer
getInteger(String jsonPath,
boolean hasdefaultElement,
Integer defaultElement,
boolean parseJsonPath)
Integer
getInteger(String jsonPath,
Integer defaultElement)
Gets an element as Integer
using the
specified JsonPath
.
protected Integer
getIntegerElement(String jsonPath,
boolean hasdefaultElement,
Integer defaultElement)
protected Integer
getIntegerFromObject(Object object)
Integer
getIntegerNoKeyParsing(String jsonPath)
Integer
getIntegerNoKeyParsing(String jsonPath,
Integer defaultElement)
JsonArray
getJsonArray(String jsonPath)
Gets an element as JsonArray
using the
specified JsonPath
.
protected JsonArray
getJsonArray(String jsonPath,
boolean hasdefaultElement,
JsonArray defaultElement,
boolean parseJsonPath)
JsonArray
getJsonArray(String jsonPath,
JsonArray defaultElement)
Gets an element as JsonArray
using the
specified JsonPath
.
protected JsonArray
getJsonArrayFromObject(Object object)
JsonArray
getJsonArrayNoKeyParsing(String jsonPath)
JsonArray
getJsonArrayNoKeyParsing(String jsonPath,
JsonArray defaultElement)
JsonArray
getJsonArrayOrEmpty(String jsonPath)
Gets an element as JsonArray
using the
specified JsonPath
.
JsonArray
getJsonArrayOrEmpty(String jsonPath,
boolean addIfDoesntExist)
Gets an element as JsonArray
using the
specified JsonPath
.
JsonArray
getJsonArrayOrEmptyNoKeyParsing(String jsonPath)
protected JsonManager
getJsonManager()
JsonObject
getJsonObject(String jsonPath)
Gets an element as JsonObject
using the
specified JsonPath
.
protected JsonObject
getJsonObject(String jsonPath,
boolean hasdefaultElement,
JsonObject defaultElement)
protected JsonObject
getJsonObject(String jsonPath,
boolean hasdefaultElement,
JsonObject defaultElement,
boolean parseJsonPath)
JsonObject
getJsonObject(String jsonPath,
JsonObject defaultElement)
Gets an element as JsonObject
using the
specified JsonPath
.
protected JsonObject
getJsonObjectFromObject(Object object)
JsonObject
getJsonObjectNoKeyParsing(String jsonPath)
JsonObject
getJsonObjectNoKeyParsing(String jsonPath,
JsonObject defaultElement)
JsonObject
getJsonObjectOrEmpty(String jsonPath)
Gets an element as JsonObject
using the
specified JsonPath
.
JsonObject
getJsonObjectOrEmpty(String jsonPath,
boolean addIfDoesntExist)
Gets an element as JsonObject
using the
specified JsonPath
.
JsonObject
getJsonObjectOrEmptyNoKeyParsing(String jsonPath)
protected Map<String,JsonObjectArrayBase.JsonPathCachingItem>
getJsonPathCachingMap()
Long
getLong(String jsonPath)
Gets an element as Long
using the
specified JsonPath
.
protected Long
getLong(String jsonPath,
boolean hasdefaultElement,
Long defaultElement,
boolean parseJsonPath)
Long
getLong(String jsonPath,
Long defaultElement)
Gets an element as Long
using the
specified JsonPath
.
protected Long
getLongElement(String jsonPath,
boolean hasdefaultElement,
Long defaultElement)
protected Long
getLongFromObject(Object object)
Long
getLongNoKeyParsing(String jsonPath)
Long
getLongNoKeyParsing(String jsonPath,
Long defaultElement)
Object
getObject(String jsonPath)
Gets an untyped Object using the
specified JsonPath
.
protected Object
getObject(String jsonPath,
boolean hasdefaultElement,
Object defaultElement,
boolean parseJsonPath)
Object
getObject(String jsonPath,
Object defaultElement)
Gets an untyped Object using the
specified JsonPath
.
protected ObjectConverter
getObjectConverter()
Object
getObjectNoKeyParsing(String jsonPath)
Object
getObjectNoKeyParsing(String jsonPath,
Object defaultElement)
protected SpincastUtils
getSpincastUtils()
String
getString(String jsonPath)
Gets an element as String
using the
specified JsonPath
.
protected String
getString(String jsonPath,
boolean hasdefaultElement,
String defaultElement)
protected String
getString(String jsonPath,
boolean hasdefaultElement,
String defaultElement,
boolean parseJsonPath)
String
getString(String jsonPath,
String defaultElement)
Gets an element as String
using the
specified JsonPath
.
protected String
getStringFromObject(Object object)
String
getStringNoKeyParsing(String jsonPath)
String
getStringNoKeyParsing(String jsonPath,
String defaultElement)
protected ElementTransformer
getTrimTransformer()
boolean
isCanBeConvertedToBigDecimal(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type BigDecimal
, or can be
converted and retrieved as one.
protected boolean
isCanBeConvertedToBigDecimal(String jsonPath,
boolean parseKey)
boolean
isCanBeConvertedToBigDecimalNoKeyParsing(String jsonPath)
boolean
isCanBeConvertedToBoolean(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Boolean
, or can be
converted and retrieved as one.
protected boolean
isCanBeConvertedToBoolean(String jsonPath,
boolean parseKey)
boolean
isCanBeConvertedToBooleanNoKeyParsing(String jsonPath)
boolean
isCanBeConvertedToByteArray(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type base 64 String
representing
a byte array, or can be converted and retrieved as one.
protected boolean
isCanBeConvertedToByteArray(String jsonPath,
boolean parseKey)
boolean
isCanBeConvertedToByteArrayNoKeyParsing(String jsonPath)
boolean
isCanBeConvertedToDate(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Date
, or can be
converted and retrieved as one.
protected boolean
isCanBeConvertedToDate(String jsonPath,
boolean parseKey)
boolean
isCanBeConvertedToDateNoKeyParsing(String jsonPath)
boolean
isCanBeConvertedToDouble(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Double
, or can be
converted and retrieved as one.
protected boolean
isCanBeConvertedToDouble(String jsonPath,
boolean parseKey)
boolean
isCanBeConvertedToDoubleNoKeyParsing(String jsonPath)
boolean
isCanBeConvertedToFloat(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Float
, or can be
converted and retrieved as one.
protected boolean
isCanBeConvertedToFloat(String jsonPath,
boolean parseKey)
boolean
isCanBeConvertedToFloatNoKeyParsing(String jsonPath)
boolean
isCanBeConvertedToInteger(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Integer
, or can be
converted and retrieved as one.
protected boolean
isCanBeConvertedToInteger(String jsonPath,
boolean parseKey)
boolean
isCanBeConvertedToIntegerNoKeyParsing(String jsonPath)
boolean
isCanBeConvertedToJsonArray(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type JsonArray
, or can be
converted and retrieved as one.
protected boolean
isCanBeConvertedToJsonArray(String jsonPath,
boolean parseKey)
boolean
isCanBeConvertedToJsonArrayNoKeyParsing(String jsonPath)
boolean
isCanBeConvertedToJsonObject(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type JsonObject
, or can be
converted and retrieved as one.
protected boolean
isCanBeConvertedToJsonObject(String jsonPath,
boolean parseKey)
boolean
isCanBeConvertedToJsonObjectNoKeyParsing(String jsonPath)
boolean
isCanBeConvertedToLong(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Long
, or can be
converted and retrieved as one.
protected boolean
isCanBeConvertedToLong(String jsonPath,
boolean parseKey)
boolean
isCanBeConvertedToLongNoKeyParsing(String jsonPath)
boolean
isCanBeConvertedToString(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type String
, or can be
converted and retrieved as one.
protected boolean
isCanBeConvertedToString(String jsonPath,
boolean parseKey)
boolean
isCanBeConvertedToStringNoKeyParsing(String jsonPath)
boolean
isMutable()
Is this object/array mutable?
boolean
isNull(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is null
.
boolean
isNullNoKeyParsing(String jsonPath)
boolean
isOfTypeBigDecimal(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type BigDecimal
, without requiring
any conversion.
boolean
isOfTypeBigDecimalNoKeyParsing(String jsonPath)
boolean
isOfTypeBoolean(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Boolean
, without requiring
any conversion.
boolean
isOfTypeBoolean(String jsonPath,
boolean parseKey)
boolean
isOfTypeBooleanNoKeyParsing(String jsonPath)
boolean
isOfTypeByteArray(String jsonPath,
boolean acceptBase64StringToo)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type byte[]
, without requiring
any conversion.
boolean
isOfTypeByteArray(String jsonPath,
boolean acceptBase64StringToo,
boolean parseKey)
boolean
isOfTypeByteArrayNoKeyParsing(String jsonPath,
boolean acceptBase64StringToo)
boolean
isOfTypeDate(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Date
, without requiring
any conversion.
boolean
isOfTypeDate(String jsonPath,
boolean parseKey)
boolean
isOfTypeDateNoKeyParsing(String jsonPath)
boolean
isOfTypeDouble(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Double
, without requiring
any conversion.
boolean
isOfTypeDouble(String jsonPath,
boolean parseKey)
boolean
isOfTypeDoubleNoKeyParsing(String jsonPath)
boolean
isOfTypeeBigDecimal(String jsonPath,
boolean parseKey)
boolean
isOfTypeFloat(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Float
, without requiring
any conversion.
boolean
isOfTypeFloat(String jsonPath,
boolean parseKey)
boolean
isOfTypeFloatNoKeyParsing(String jsonPath)
boolean
isOfTypeInteger(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Integer
, without requiring
any conversion.
boolean
isOfTypeInteger(String jsonPath,
boolean parseKey)
boolean
isOfTypeIntegerNoKeyParsing(String jsonPath)
boolean
isOfTypeJsonArray(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type JsonArray
, without requiring
any conversion.
boolean
isOfTypeJsonArray(String jsonPath,
boolean parseKey)
boolean
isOfTypeJsonArrayNoKeyParsing(String jsonPath)
boolean
isOfTypeJsonObject(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type JsonObject
, without requiring
any conversion.
boolean
isOfTypeJsonObject(String jsonPath,
boolean parseKey)
boolean
isOfTypeJsonObjectNoKeyParsing(String jsonPath)
boolean
isOfTypeLong(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Long
, without requiring
any conversion.
boolean
isOfTypeLong(String jsonPath,
boolean parseKey)
boolean
isOfTypeLongNoKeyParsing(String jsonPath)
boolean
isOfTypeString(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type String
, without requiring
any conversion.
boolean
isOfTypeString(String jsonPath,
boolean parseKey)
boolean
isOfTypeStringNoKeyParsing(String jsonPath)
protected JsonObjectOrArray
put(String jsonPath,
Object element,
boolean clone,
boolean parseJsonPath)
protected abstract JsonObjectOrArray
putAsIs(String key,
Object element)
JsonObjectOrArray
set(String jsonPath,
Object element)
Sets an element at the specified JsonPath
.
JsonObjectOrArray
set(String jsonPath,
Object element,
boolean clone)
Sets an element at the specified JsonPath
.
String
toJsonString()
The Json
string representation
of the object.
String
toJsonString(boolean pretty)
The Json
string representation
of the object.
String
toString()
void
transform(String jsonPath,
ElementTransformer transformer)
Transforms the element at the specified JsonPath
using
the transformer.
void
transformAll(ElementTransformer transformer)
Transforms all the elements of the object, using the specified
transformer.
abstract void
transformAll(ElementTransformer transformer,
boolean recursive)
Transforms all the elements of the object, using the specified
transformer.
void
trim(String jsonPath)
Trims the element at the specified JsonPath
if
it's of type String
.
void
trimAll()
Trims all the elements of the object that are of type
String
.
void
trimAll(boolean recursive)
Trims all the elements of the object that are of type
String.
boolean
validateIsNull(String jsonPath,
boolean parseKey)
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.spincast.core.json.JsonObjectOrArray
clear, remove, size
-
-
Field Detail
-
logger
protected final org.slf4j.Logger logger
-
defaultElementValidator
protected final Object defaultElementValidator
-
Constructor Detail
-
JsonObjectArrayBase
public JsonObjectArrayBase(boolean mutable,
JsonManager jsonManager,
SpincastUtils spincastUtils,
ObjectConverter objectConverter)
Constructor
-
Method Detail
-
isMutable
public boolean isMutable()
Description copied from interface: JsonObjectOrArray
Is this object/array mutable?
- Specified by:
isMutable
in interface JsonObjectOrArray
-
getJsonManager
protected JsonManager getJsonManager()
-
getSpincastUtils
protected SpincastUtils getSpincastUtils()
-
getObjectConverter
protected ObjectConverter getObjectConverter()
-
getdefaultElementValidator
protected Object getdefaultElementValidator()
-
getJsonPathCachingMap
protected Map<String,JsonObjectArrayBase.JsonPathCachingItem> getJsonPathCachingMap()
-
getObject
public Object getObject(String jsonPath)
Description copied from interface: JsonObjectOrArray
Gets an untyped Object using the
specified JsonPath
.
- Specified by:
getObject
in interface JsonObjectOrArray
- Returns:
- the object or
null
if not found. This object
will necessarily be of a type managed by JsonObjectOrArray
, since
an object of any other type is automatically converted when added.
-
getObject
public Object getObject(String jsonPath,
Object defaultElement)
Description copied from interface: JsonObjectOrArray
Gets an untyped Object using the
specified JsonPath
.
- Specified by:
getObject
in interface JsonObjectOrArray
- Returns:
- the object or the specified
defaultElement
if not found. This object
will necessarily be of a type managed by JsonObjectOrArray
, since
an object of any other type is automatically converted when added.
-
getObject
protected Object getObject(String jsonPath,
boolean hasdefaultElement,
Object defaultElement,
boolean parseJsonPath)
-
getJsonObject
public JsonObject getJsonObject(String jsonPath)
Description copied from interface: JsonObjectOrArray
Gets an element as JsonObject
using the
specified JsonPath
.
- Specified by:
getJsonObject
in interface JsonObjectOrArray
- Returns:
- the object or
null
if not found.
-
getJsonObjectOrEmpty
public JsonObject getJsonObjectOrEmpty(String jsonPath)
Description copied from interface: JsonObjectOrArray
Gets an element as JsonObject
using the
specified JsonPath
.
- Specified by:
getJsonObjectOrEmpty
in interface JsonObjectOrArray
- Returns:
- the element or an empty
JsonObject
if not found or if null
. The empty
JsonObject
will not be added to the specified
path.
-
getJsonObjectOrEmpty
public JsonObject getJsonObjectOrEmpty(String jsonPath,
boolean addIfDoesntExist)
Description copied from interface: JsonObjectOrArray
Gets an element as JsonObject
using the
specified JsonPath
.
- Specified by:
getJsonObjectOrEmpty
in interface JsonObjectOrArray
addIfDoesntExist
- if true
and the element doesn't exist,
the created empty JsonObject
will be added to the specified
JsonPath
.
- Returns:
- the element or an empty
JsonObject
if not found or if null
.
-
getJsonObject
public JsonObject getJsonObject(String jsonPath,
JsonObject defaultElement)
Description copied from interface: JsonObjectOrArray
Gets an element as JsonObject
using the
specified JsonPath
.
- Specified by:
getJsonObject
in interface JsonObjectOrArray
- Returns:
- the object or the specified
defaultElement
if not found.
-
getJsonObject
protected JsonObject getJsonObject(String jsonPath,
boolean hasdefaultElement,
JsonObject defaultElement)
-
getJsonObjectNoKeyParsing
public JsonObject getJsonObjectNoKeyParsing(String jsonPath)
-
getJsonObjectNoKeyParsing
public JsonObject getJsonObjectNoKeyParsing(String jsonPath,
JsonObject defaultElement)
-
getJsonObjectOrEmptyNoKeyParsing
public JsonObject getJsonObjectOrEmptyNoKeyParsing(String jsonPath)
-
getJsonObject
protected JsonObject getJsonObject(String jsonPath,
boolean hasdefaultElement,
JsonObject defaultElement,
boolean parseJsonPath)
-
getJsonObjectFromObject
protected JsonObject getJsonObjectFromObject(Object object)
-
getJsonArray
public JsonArray getJsonArray(String jsonPath)
Description copied from interface: JsonObjectOrArray
Gets an element as JsonArray
using the
specified JsonPath
.
- Specified by:
getJsonArray
in interface JsonObjectOrArray
- Returns:
- the object or
null
if not found.
-
getJsonArrayOrEmpty
public JsonArray getJsonArrayOrEmpty(String jsonPath)
Description copied from interface: JsonObjectOrArray
Gets an element as JsonArray
using the
specified JsonPath
.
- Specified by:
getJsonArrayOrEmpty
in interface JsonObjectOrArray
- Returns:
- the element or an empty
JsonArray
if not found or if null
. The empty
JsonArray
will not be added to the specified
path.
-
getJsonArrayOrEmpty
public JsonArray getJsonArrayOrEmpty(String jsonPath,
boolean addIfDoesntExist)
Description copied from interface: JsonObjectOrArray
Gets an element as JsonArray
using the
specified JsonPath
.
- Specified by:
getJsonArrayOrEmpty
in interface JsonObjectOrArray
addIfDoesntExist
- if true
and the element doesn't exist,
the created empty JsonArray
will be added to the specified
JsonPath
.
- Returns:
- the element or an empty
JsonArray
if not found or if null
.
-
getJsonArray
public JsonArray getJsonArray(String jsonPath,
JsonArray defaultElement)
Description copied from interface: JsonObjectOrArray
Gets an element as JsonArray
using the
specified JsonPath
.
- Specified by:
getJsonArray
in interface JsonObjectOrArray
- Returns:
- the object or the specified
defaultElement
if not found.
-
getJsonArrayNoKeyParsing
public JsonArray getJsonArrayNoKeyParsing(String jsonPath,
JsonArray defaultElement)
-
getJsonArray
protected JsonArray getJsonArray(String jsonPath,
boolean hasdefaultElement,
JsonArray defaultElement,
boolean parseJsonPath)
-
getString
public String getString(String jsonPath)
Description copied from interface: JsonObjectOrArray
Gets an element as String
using the
specified JsonPath
.
- Specified by:
getString
in interface JsonObjectOrArray
- Returns:
- the element or
null
if not found.
-
getString
public String getString(String jsonPath,
String defaultElement)
Description copied from interface: JsonObjectOrArray
Gets an element as String
using the
specified JsonPath
.
- Specified by:
getString
in interface JsonObjectOrArray
- Returns:
- the element or the specified
defaultElement
if not found.
-
getString
protected String getString(String jsonPath,
boolean hasdefaultElement,
String defaultElement)
-
getString
protected String getString(String jsonPath,
boolean hasdefaultElement,
String defaultElement,
boolean parseJsonPath)
-
getInteger
public Integer getInteger(String jsonPath)
Description copied from interface: JsonObjectOrArray
Gets an element as Integer
using the
specified JsonPath
.
- Specified by:
getInteger
in interface JsonObjectOrArray
- Returns:
- the element or
null
if not found.
-
getInteger
public Integer getInteger(String jsonPath,
Integer defaultElement)
Description copied from interface: JsonObjectOrArray
Gets an element as Integer
using the
specified JsonPath
.
- Specified by:
getInteger
in interface JsonObjectOrArray
- Returns:
- the element or the specified
defaultElement
if not found.
-
getIntegerElement
protected Integer getIntegerElement(String jsonPath,
boolean hasdefaultElement,
Integer defaultElement)
-
getIntegerNoKeyParsing
public Integer getIntegerNoKeyParsing(String jsonPath,
Integer defaultElement)
-
getInteger
protected Integer getInteger(String jsonPath,
boolean hasdefaultElement,
Integer defaultElement,
boolean parseJsonPath)
-
getLong
public Long getLong(String jsonPath)
Description copied from interface: JsonObjectOrArray
Gets an element as Long
using the
specified JsonPath
.
- Specified by:
getLong
in interface JsonObjectOrArray
- Returns:
- the element or
null
if not found.
-
getLong
public Long getLong(String jsonPath,
Long defaultElement)
Description copied from interface: JsonObjectOrArray
Gets an element as Long
using the
specified JsonPath
.
- Specified by:
getLong
in interface JsonObjectOrArray
- Returns:
- the element or the specified
defaultElement
if not found.
-
getLongElement
protected Long getLongElement(String jsonPath,
boolean hasdefaultElement,
Long defaultElement)
-
getLong
protected Long getLong(String jsonPath,
boolean hasdefaultElement,
Long defaultElement,
boolean parseJsonPath)
-
getFloat
public Float getFloat(String jsonPath)
Description copied from interface: JsonObjectOrArray
Gets an element as Float
using the
specified JsonPath
.
- Specified by:
getFloat
in interface JsonObjectOrArray
- Returns:
- the element or
null
if not found.
-
getFloat
public Float getFloat(String jsonPath,
Float defaultElement)
Description copied from interface: JsonObjectOrArray
Gets an element as Float
using the
specified JsonPath
.
- Specified by:
getFloat
in interface JsonObjectOrArray
- Returns:
- the element or the specified
defaultElement
if not found.
-
getFloatElement
protected Float getFloatElement(String jsonPath,
boolean hasdefaultElement,
Float defaultElement)
-
getFloat
protected Float getFloat(String jsonPath,
boolean hasdefaultElement,
Float defaultElement,
boolean parseJsonPath)
-
getDouble
public Double getDouble(String jsonPath)
Description copied from interface: JsonObjectOrArray
Gets an element as Double
using the
specified JsonPath
.
- Specified by:
getDouble
in interface JsonObjectOrArray
- Returns:
- the element or
null
if not found.
-
getDouble
public Double getDouble(String jsonPath,
Double defaultElement)
Description copied from interface: JsonObjectOrArray
Gets an element as Double
using the
specified JsonPath
.
- Specified by:
getDouble
in interface JsonObjectOrArray
- Returns:
- the element or the specified
defaultElement
if not found.
-
getDoubleElement
protected Double getDoubleElement(String jsonPath,
boolean hasdefaultElement,
Double defaultElement)
-
getDouble
protected Double getDouble(String jsonPath,
boolean hasdefaultElement,
Double defaultElement,
boolean parseJsonPath)
-
getBoolean
public Boolean getBoolean(String jsonPath)
Description copied from interface: JsonObjectOrArray
Gets an element as Boolean
using the
specified JsonPath
.
- Specified by:
getBoolean
in interface JsonObjectOrArray
- Returns:
- the element or
null
if not found.
-
getBoolean
public Boolean getBoolean(String jsonPath,
Boolean defaultElement)
Description copied from interface: JsonObjectOrArray
Gets an element as Boolean
using the
specified JsonPath
.
- Specified by:
getBoolean
in interface JsonObjectOrArray
- Returns:
- the element or the specified
defaultElement
if not found.
-
getBooleanElement
protected Boolean getBooleanElement(String jsonPath,
boolean hasdefaultElement,
Boolean defaultElement)
-
getBooleanNoKeyParsing
public Boolean getBooleanNoKeyParsing(String jsonPath,
Boolean defaultElement)
-
getBoolean
protected Boolean getBoolean(String jsonPath,
boolean hasdefaultElement,
Boolean defaultElement,
boolean parseJsonPath)
-
getBigDecimal
public BigDecimal getBigDecimal(String jsonPath)
Description copied from interface: JsonObjectOrArray
Gets an element as BigDecimal
using the
specified JsonPath
.
- Specified by:
getBigDecimal
in interface JsonObjectOrArray
- Returns:
- the element or
null
if not found.
-
getBigDecimal
public BigDecimal getBigDecimal(String jsonPath,
BigDecimal defaultElement)
Description copied from interface: JsonObjectOrArray
Gets an element as BigDecimal
using the
specified JsonPath
.
- Specified by:
getBigDecimal
in interface JsonObjectOrArray
- Returns:
- the element or the specified
defaultElement
if not found.
-
getBigDecimalElement
protected BigDecimal getBigDecimalElement(String jsonPath,
boolean hasdefaultElement,
BigDecimal defaultElement)
-
getBigDecimalNoKeyParsing
public BigDecimal getBigDecimalNoKeyParsing(String jsonPath)
-
getBigDecimalNoKeyParsing
public BigDecimal getBigDecimalNoKeyParsing(String jsonPath,
BigDecimal defaultElement)
-
getBigDecimal
protected BigDecimal getBigDecimal(String jsonPath,
boolean hasdefaultElement,
BigDecimal defaultElement,
boolean parseJsonPath)
-
getBigDecimalFromObject
protected BigDecimal getBigDecimalFromObject(Object object)
-
getBytesFromBase64String
public byte[] getBytesFromBase64String(String jsonPath)
Description copied from interface: JsonObjectOrArray
Gets a byte array, from a base 64 encoded element using the
specified JsonPath
.
- Specified by:
getBytesFromBase64String
in interface JsonObjectOrArray
- Returns:
- the element or
null
if not found.
-
getBytesFromBase64String
public byte[] getBytesFromBase64String(String jsonPath,
byte[] defaultElement)
Description copied from interface: JsonObjectOrArray
Gets a byte array, from a base 64 encoded element using the
specified JsonPath
.
- Specified by:
getBytesFromBase64String
in interface JsonObjectOrArray
- Returns:
- the element or the specified
defaultElement
if not found.
-
getBytesFromBase64StringElement
protected byte[] getBytesFromBase64StringElement(String jsonPath,
boolean hasdefaultElement,
byte[] defaultElement)
-
getBytesFromBase64StringNoKeyParsing
public byte[] getBytesFromBase64StringNoKeyParsing(String jsonPath)
-
getBytesFromBase64StringNoKeyParsing
public byte[] getBytesFromBase64StringNoKeyParsing(String jsonPath,
byte[] defaultElement)
-
getBytesFromBase64String
protected byte[] getBytesFromBase64String(String jsonPath,
boolean hasdefaultElement,
byte[] defaultElement,
boolean parseJsonPath)
-
getBytesFromBase64StringValueFromObject
protected byte[] getBytesFromBase64StringValueFromObject(Object object)
-
getDate
public Date getDate(String jsonPath)
Description copied from interface: JsonObjectOrArray
Gets a UTC timezoned date from a ISO 8601
date string element using the
specified JsonPath
.
- Specified by:
getDate
in interface JsonObjectOrArray
- Returns:
- the element or
null
if not found.
-
getDate
public Date getDate(String jsonPath,
Date defaultElement)
Description copied from interface: JsonObjectOrArray
Gets a UTC timezoned date from a ISO 8601
date string element using the
specified JsonPath
.
- Specified by:
getDate
in interface JsonObjectOrArray
- Returns:
- the element or the specified
defaultElement
if not found.
-
getDateElement
protected Date getDateElement(String jsonPath,
boolean hasdefaultElement,
Date defaultElement)
-
getDate
protected Date getDate(String jsonPath,
boolean hasdefaultElement,
Date defaultElement,
boolean parseJsonPath)
-
getInstant
public Instant getInstant(String jsonPath)
throws CantConvertException
Description copied from interface: JsonObjectOrArray
Gets an Instant from a ISO 8601
date string element using the
specified JsonPath
.
- Specified by:
getInstant
in interface JsonObjectOrArray
- Returns:
- the element or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getInstant
public Instant getInstant(String jsonPath,
Instant defaultElement)
throws CantConvertException
Description copied from interface: JsonObjectOrArray
Gets an Instant from a ISO 8601
date string element using the
specified JsonPath
.
- Specified by:
getInstant
in interface JsonObjectOrArray
- Returns:
- the element or the specified
defaultElement
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getInstantElement
protected Instant getInstantElement(String jsonPath,
boolean hasdefaultElement,
Instant defaultElement)
-
getInstantNoKeyParsing
public Instant getInstantNoKeyParsing(String jsonPath,
Instant defaultElement)
-
getInstant
protected Instant getInstant(String jsonPath,
boolean hasdefaultElement,
Instant defaultElement,
boolean parseJsonPath)
-
getArrayFirst
protected <T> T getArrayFirst(String jsonPath,
boolean parseJsonPath,
boolean hasdefaultElement,
T defaultElement,
JsonObjectDefault.IFirstElementGetter<T> firstElementGetter)
-
getArrayFirstString
public String getArrayFirstString(String key)
Description copied from interface: JsonObjectOrArray
Gets the first value (as String) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstString
in interface JsonObjectOrArray
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
-
getArrayFirstString
public String getArrayFirstString(String key,
String defaultElement)
Description copied from interface: JsonObjectOrArray
Gets the first value (as String) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstString
in interface JsonObjectOrArray
- Returns:
- the value of the property or the specified
defaultElement
if the array or
the first element are not found.
-
getArrayFirstStringNoKeyParsing
public String getArrayFirstStringNoKeyParsing(String key,
String defaultElement)
-
getArrayFirstString
protected String getArrayFirstString(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
String defaultElement)
-
toJsonString
public String toJsonString()
Description copied from interface: JsonObjectOrArray
The Json
string representation
of the object.
- Specified by:
toJsonString
in interface JsonObjectOrArray
-
toJsonString
public String toJsonString(boolean pretty)
Description copied from interface: JsonObjectOrArray
The Json
string representation
of the object.
- Specified by:
toJsonString
in interface JsonObjectOrArray
- Parameters:
pretty
- if true
, the generated String will
be formatted.
-
getArrayFirstJsonObject
public JsonObject getArrayFirstJsonObject(String key)
Description copied from interface: JsonObjectOrArray
Gets the first value (as JsonObject) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstJsonObject
in interface JsonObjectOrArray
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
-
getArrayFirstJsonObject
public JsonObject getArrayFirstJsonObject(String key,
JsonObject defaultElement)
Description copied from interface: JsonObjectOrArray
Gets the first value (as JsonObject) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstJsonObject
in interface JsonObjectOrArray
- Returns:
- the value of the property or the specified
defaultElement
if the array or
the first element are not found.
-
getArrayFirstJsonObjectNoKeyParsing
public JsonObject getArrayFirstJsonObjectNoKeyParsing(String key)
-
getArrayFirstJsonObjectNoKeyParsing
public JsonObject getArrayFirstJsonObjectNoKeyParsing(String key,
JsonObject defaultElement)
-
getArrayFirstJsonObject
protected JsonObject getArrayFirstJsonObject(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
JsonObject defaultElement)
-
getArrayFirstJsonArray
public JsonArray getArrayFirstJsonArray(String key)
Description copied from interface: JsonObjectOrArray
Gets the first value (as JsonArray) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstJsonArray
in interface JsonObjectOrArray
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
-
getArrayFirstJsonArray
public JsonArray getArrayFirstJsonArray(String key,
JsonArray defaultElement)
Description copied from interface: JsonObjectOrArray
Gets the first value (as JsonArray) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstJsonArray
in interface JsonObjectOrArray
- Returns:
- the value of the property or the specified
defaultElement
if the array or
the first element are not found.
-
getArrayFirstJsonArrayNoKeyParsing
public JsonArray getArrayFirstJsonArrayNoKeyParsing(String key,
JsonArray defaultElement)
-
getArrayFirstJsonArray
protected JsonArray getArrayFirstJsonArray(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
JsonArray defaultElement)
-
getArrayFirstInteger
public Integer getArrayFirstInteger(String key)
Description copied from interface: JsonObjectOrArray
Gets the first value (as Integer) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstInteger
in interface JsonObjectOrArray
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
-
getArrayFirstInteger
public Integer getArrayFirstInteger(String key,
Integer defaultElement)
Description copied from interface: JsonObjectOrArray
Gets the first value (as Integer) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstInteger
in interface JsonObjectOrArray
- Returns:
- the value of the property or the specified
defaultElement
if the array or
the first element are not found.
-
getArrayFirstIntegerNoKeyParsing
public Integer getArrayFirstIntegerNoKeyParsing(String key,
Integer defaultElement)
-
getArrayFirstInteger
protected Integer getArrayFirstInteger(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
Integer defaultElement)
-
getArrayFirstLong
public Long getArrayFirstLong(String key)
Description copied from interface: JsonObjectOrArray
Gets the first value (as Long) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstLong
in interface JsonObjectOrArray
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
-
getArrayFirstLong
public Long getArrayFirstLong(String key,
Long defaultElement)
Description copied from interface: JsonObjectOrArray
Gets the first value (as Long) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstLong
in interface JsonObjectOrArray
- Returns:
- the value of the property or the specified
defaultElement
if the array or
the first element are not found.
-
getArrayFirstLongNoKeyParsing
public Long getArrayFirstLongNoKeyParsing(String key,
Long defaultElement)
-
getArrayFirstLong
protected Long getArrayFirstLong(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
Long defaultElement)
-
getArrayFirstDouble
public Double getArrayFirstDouble(String key)
Description copied from interface: JsonObjectOrArray
Gets the first value (as Double) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstDouble
in interface JsonObjectOrArray
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
-
getArrayFirstDouble
public Double getArrayFirstDouble(String key,
Double defaultElement)
Description copied from interface: JsonObjectOrArray
Gets the first value (as Double) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstDouble
in interface JsonObjectOrArray
- Returns:
- the value of the property or the specified
defaultElement
if the array or
the first element are not found.
-
getArrayFirstDoubleNoKeyParsing
public Double getArrayFirstDoubleNoKeyParsing(String key,
Double defaultElement)
-
getArrayFirstDouble
protected Double getArrayFirstDouble(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
Double defaultElement)
-
getArrayFirstFloat
public Float getArrayFirstFloat(String key)
Description copied from interface: JsonObjectOrArray
Gets the first value (as Float) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstFloat
in interface JsonObjectOrArray
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
-
getArrayFirstFloat
public Float getArrayFirstFloat(String key,
Float defaultElement)
Description copied from interface: JsonObjectOrArray
Gets the first value (as Float) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstFloat
in interface JsonObjectOrArray
- Returns:
- the value of the property or the specified
defaultElement
if the array or
the first element are not found.
-
getArrayFirstFloatNoKeyParsing
public Float getArrayFirstFloatNoKeyParsing(String key,
Float defaultElement)
-
getArrayFirstFloat
protected Float getArrayFirstFloat(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
Float defaultElement)
-
getArrayFirstBoolean
public Boolean getArrayFirstBoolean(String key)
Description copied from interface: JsonObjectOrArray
Gets the first value (as Boolean) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstBoolean
in interface JsonObjectOrArray
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
-
getArrayFirstBoolean
public Boolean getArrayFirstBoolean(String key,
Boolean defaultElement)
Description copied from interface: JsonObjectOrArray
Gets the first value (as Boolean) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstBoolean
in interface JsonObjectOrArray
- Returns:
- the value of the property or the specified
defaultElement
if the array or
the first element are not found.
-
getArrayFirstBooleanNoKeyParsing
public Boolean getArrayFirstBooleanNoKeyParsing(String key,
Boolean defaultElement)
-
getArrayFirstBoolean
protected Boolean getArrayFirstBoolean(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
Boolean defaultElement)
-
getArrayFirstBigDecimal
public BigDecimal getArrayFirstBigDecimal(String key)
Description copied from interface: JsonObjectOrArray
Gets the first value (as BigDecimal) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstBigDecimal
in interface JsonObjectOrArray
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
-
getArrayFirstBigDecimal
public BigDecimal getArrayFirstBigDecimal(String key,
BigDecimal defaultElement)
Description copied from interface: JsonObjectOrArray
Gets the first value (as BigDecimal) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstBigDecimal
in interface JsonObjectOrArray
- Returns:
- the value of the property or the specified
defaultElement
if the array or
the first element are not found.
-
getArrayFirstBigDecimalNoKeyParsing
public BigDecimal getArrayFirstBigDecimalNoKeyParsing(String key)
-
getArrayFirstBigDecimalNoKeyParsing
public BigDecimal getArrayFirstBigDecimalNoKeyParsing(String key,
BigDecimal defaultElement)
-
getArrayFirstBigDecimal
protected BigDecimal getArrayFirstBigDecimal(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
BigDecimal defaultElement)
-
getArrayFirstBytesFromBase64String
public byte[] getArrayFirstBytesFromBase64String(String key)
Description copied from interface: JsonObjectOrArray
Gets the first value (as byte[]) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstBytesFromBase64String
in interface JsonObjectOrArray
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
-
getArrayFirstBytesFromBase64String
public byte[] getArrayFirstBytesFromBase64String(String key,
byte[] defaultElement)
Description copied from interface: JsonObjectOrArray
Gets the first value (as byte[]) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstBytesFromBase64String
in interface JsonObjectOrArray
- Returns:
- the value of the property or the specified
defaultElement
if the array or
the first element are not found.
-
getArrayFirstBytesFromBase64StringNoKeyParsing
public byte[] getArrayFirstBytesFromBase64StringNoKeyParsing(String key)
-
getArrayFirstBytesFromBase64StringNoKeyParsing
public byte[] getArrayFirstBytesFromBase64StringNoKeyParsing(String key,
byte[] defaultElement)
-
getArrayFirstBytesFromBase64String
protected byte[] getArrayFirstBytesFromBase64String(String key,
boolean parseJsonPath,
boolean hasdefaultElement,
byte[] defaultElement)
-
getArrayFirstDate
public Date getArrayFirstDate(String key)
Description copied from interface: JsonObjectOrArray
Gets the first value (as Date) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstDate
in interface JsonObjectOrArray
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
-
getArrayFirstDate
public Date getArrayFirstDate(String key,
Date defaultElement)
Description copied from interface: JsonObjectOrArray
Gets the first value (as Date) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstDate
in interface JsonObjectOrArray
- Returns:
- the value of the property or the specified
defaultElement
if the array or
the first element are not found.
-
getArrayFirstDateNoKeyParsing
public Date getArrayFirstDateNoKeyParsing(String key,
Date defaultElement)
-
getArrayFirstDate
protected Date getArrayFirstDate(String jsonPath,
boolean parseJsonPath,
boolean hasdefaultElement,
Date defaultElement)
-
getArrayFirstInstant
public Instant getArrayFirstInstant(String key)
Description copied from interface: JsonObjectOrArray
Gets the first value (as Instant) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstInstant
in interface JsonObjectOrArray
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
-
getArrayFirstInstant
public Instant getArrayFirstInstant(String key,
Instant defaultElement)
Description copied from interface: JsonObjectOrArray
Gets the first value (as Instant) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Specified by:
getArrayFirstInstant
in interface JsonObjectOrArray
- Returns:
- the value of the property or the specified
defaultElement
if the array or
the first element are not found.
-
getArrayFirstInstantNoKeyParsing
public Instant getArrayFirstInstantNoKeyParsing(String key,
Instant defaultElement)
-
getArrayFirstInstant
protected Instant getArrayFirstInstant(String jsonPath,
boolean parseJsonPath,
boolean hasdefaultElement,
Instant defaultElement)
-
isCanBeConvertedToString
public boolean isCanBeConvertedToString(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
, of type String
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToString
in interface JsonObjectOrArray
-
isCanBeConvertedToStringNoKeyParsing
public boolean isCanBeConvertedToStringNoKeyParsing(String jsonPath)
-
isCanBeConvertedToString
protected boolean isCanBeConvertedToString(String jsonPath,
boolean parseKey)
-
isCanBeConvertedToInteger
public boolean isCanBeConvertedToInteger(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Integer
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToInteger
in interface JsonObjectOrArray
-
isCanBeConvertedToIntegerNoKeyParsing
public boolean isCanBeConvertedToIntegerNoKeyParsing(String jsonPath)
-
isCanBeConvertedToInteger
protected boolean isCanBeConvertedToInteger(String jsonPath,
boolean parseKey)
-
isCanBeConvertedToLong
public boolean isCanBeConvertedToLong(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Long
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToLong
in interface JsonObjectOrArray
-
isCanBeConvertedToLongNoKeyParsing
public boolean isCanBeConvertedToLongNoKeyParsing(String jsonPath)
-
isCanBeConvertedToLong
protected boolean isCanBeConvertedToLong(String jsonPath,
boolean parseKey)
-
isCanBeConvertedToFloat
public boolean isCanBeConvertedToFloat(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Float
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToFloat
in interface JsonObjectOrArray
-
isCanBeConvertedToFloatNoKeyParsing
public boolean isCanBeConvertedToFloatNoKeyParsing(String jsonPath)
-
isCanBeConvertedToFloat
protected boolean isCanBeConvertedToFloat(String jsonPath,
boolean parseKey)
-
isCanBeConvertedToDouble
public boolean isCanBeConvertedToDouble(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Double
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToDouble
in interface JsonObjectOrArray
-
isCanBeConvertedToDoubleNoKeyParsing
public boolean isCanBeConvertedToDoubleNoKeyParsing(String jsonPath)
-
isCanBeConvertedToDouble
protected boolean isCanBeConvertedToDouble(String jsonPath,
boolean parseKey)
-
isCanBeConvertedToBoolean
public boolean isCanBeConvertedToBoolean(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Boolean
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToBoolean
in interface JsonObjectOrArray
-
isCanBeConvertedToBooleanNoKeyParsing
public boolean isCanBeConvertedToBooleanNoKeyParsing(String jsonPath)
-
isCanBeConvertedToBoolean
protected boolean isCanBeConvertedToBoolean(String jsonPath,
boolean parseKey)
-
isCanBeConvertedToBigDecimal
public boolean isCanBeConvertedToBigDecimal(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
, of type BigDecimal
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToBigDecimal
in interface JsonObjectOrArray
-
isCanBeConvertedToBigDecimalNoKeyParsing
public boolean isCanBeConvertedToBigDecimalNoKeyParsing(String jsonPath)
-
isCanBeConvertedToBigDecimal
protected boolean isCanBeConvertedToBigDecimal(String jsonPath,
boolean parseKey)
-
isCanBeConvertedToByteArray
public boolean isCanBeConvertedToByteArray(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
, of type base 64 String
representing
a byte array, or can be converted and retrieved as one.
- Specified by:
isCanBeConvertedToByteArray
in interface JsonObjectOrArray
-
isCanBeConvertedToByteArrayNoKeyParsing
public boolean isCanBeConvertedToByteArrayNoKeyParsing(String jsonPath)
-
isCanBeConvertedToByteArray
protected boolean isCanBeConvertedToByteArray(String jsonPath,
boolean parseKey)
-
isCanBeConvertedToDate
public boolean isCanBeConvertedToDate(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Date
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToDate
in interface JsonObjectOrArray
-
isCanBeConvertedToDateNoKeyParsing
public boolean isCanBeConvertedToDateNoKeyParsing(String jsonPath)
-
isCanBeConvertedToDate
protected boolean isCanBeConvertedToDate(String jsonPath,
boolean parseKey)
-
isCanBeConvertedToJsonObject
public boolean isCanBeConvertedToJsonObject(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
, of type JsonObject
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToJsonObject
in interface JsonObjectOrArray
-
isCanBeConvertedToJsonObjectNoKeyParsing
public boolean isCanBeConvertedToJsonObjectNoKeyParsing(String jsonPath)
-
isCanBeConvertedToJsonObject
protected boolean isCanBeConvertedToJsonObject(String jsonPath,
boolean parseKey)
-
isCanBeConvertedToJsonArray
public boolean isCanBeConvertedToJsonArray(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
, of type JsonArray
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToJsonArray
in interface JsonObjectOrArray
-
isCanBeConvertedToJsonArrayNoKeyParsing
public boolean isCanBeConvertedToJsonArrayNoKeyParsing(String jsonPath)
-
isCanBeConvertedToJsonArray
protected boolean isCanBeConvertedToJsonArray(String jsonPath,
boolean parseKey)
-
isOfTypeString
public boolean isOfTypeString(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
or of type String
, without requiring
any conversion.
- Specified by:
isOfTypeString
in interface JsonObjectOrArray
-
isOfTypeStringNoKeyParsing
public boolean isOfTypeStringNoKeyParsing(String jsonPath)
-
isOfTypeString
public boolean isOfTypeString(String jsonPath,
boolean parseKey)
-
isOfTypeInteger
public boolean isOfTypeInteger(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Integer
, without requiring
any conversion.
- Specified by:
isOfTypeInteger
in interface JsonObjectOrArray
-
isOfTypeIntegerNoKeyParsing
public boolean isOfTypeIntegerNoKeyParsing(String jsonPath)
-
isOfTypeInteger
public boolean isOfTypeInteger(String jsonPath,
boolean parseKey)
-
isOfTypeLong
public boolean isOfTypeLong(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Long
, without requiring
any conversion.
- Specified by:
isOfTypeLong
in interface JsonObjectOrArray
-
isOfTypeLongNoKeyParsing
public boolean isOfTypeLongNoKeyParsing(String jsonPath)
-
isOfTypeLong
public boolean isOfTypeLong(String jsonPath,
boolean parseKey)
-
isOfTypeFloat
public boolean isOfTypeFloat(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Float
, without requiring
any conversion.
- Specified by:
isOfTypeFloat
in interface JsonObjectOrArray
-
isOfTypeFloatNoKeyParsing
public boolean isOfTypeFloatNoKeyParsing(String jsonPath)
-
isOfTypeFloat
public boolean isOfTypeFloat(String jsonPath,
boolean parseKey)
-
isOfTypeDouble
public boolean isOfTypeDouble(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Double
, without requiring
any conversion.
- Specified by:
isOfTypeDouble
in interface JsonObjectOrArray
-
isOfTypeDoubleNoKeyParsing
public boolean isOfTypeDoubleNoKeyParsing(String jsonPath)
-
isOfTypeDouble
public boolean isOfTypeDouble(String jsonPath,
boolean parseKey)
-
isOfTypeBoolean
public boolean isOfTypeBoolean(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Boolean
, without requiring
any conversion.
- Specified by:
isOfTypeBoolean
in interface JsonObjectOrArray
-
isOfTypeBooleanNoKeyParsing
public boolean isOfTypeBooleanNoKeyParsing(String jsonPath)
-
isOfTypeBoolean
public boolean isOfTypeBoolean(String jsonPath,
boolean parseKey)
-
isOfTypeBigDecimal
public boolean isOfTypeBigDecimal(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
or of type BigDecimal
, without requiring
any conversion.
- Specified by:
isOfTypeBigDecimal
in interface JsonObjectOrArray
-
isOfTypeBigDecimalNoKeyParsing
public boolean isOfTypeBigDecimalNoKeyParsing(String jsonPath)
-
isOfTypeeBigDecimal
public boolean isOfTypeeBigDecimal(String jsonPath,
boolean parseKey)
-
isOfTypeByteArray
public boolean isOfTypeByteArray(String jsonPath,
boolean acceptBase64StringToo)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
or of type byte[]
, without requiring
any conversion.
- Specified by:
isOfTypeByteArray
in interface JsonObjectOrArray
acceptBase64StringToo
- if true
, then a valid base 64 String
will also be accepted.
-
isOfTypeByteArrayNoKeyParsing
public boolean isOfTypeByteArrayNoKeyParsing(String jsonPath,
boolean acceptBase64StringToo)
-
isOfTypeByteArray
public boolean isOfTypeByteArray(String jsonPath,
boolean acceptBase64StringToo,
boolean parseKey)
-
isOfTypeDate
public boolean isOfTypeDate(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Date
, without requiring
any conversion.
- Specified by:
isOfTypeDate
in interface JsonObjectOrArray
-
isOfTypeDateNoKeyParsing
public boolean isOfTypeDateNoKeyParsing(String jsonPath)
-
isOfTypeDate
public boolean isOfTypeDate(String jsonPath,
boolean parseKey)
-
isOfTypeJsonObject
public boolean isOfTypeJsonObject(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
or of type JsonObject
, without requiring
any conversion.
- Specified by:
isOfTypeJsonObject
in interface JsonObjectOrArray
-
isOfTypeJsonObjectNoKeyParsing
public boolean isOfTypeJsonObjectNoKeyParsing(String jsonPath)
-
isOfTypeJsonObject
public boolean isOfTypeJsonObject(String jsonPath,
boolean parseKey)
-
isOfTypeJsonArray
public boolean isOfTypeJsonArray(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is currently null
or of type JsonArray
, without requiring
any conversion.
- Specified by:
isOfTypeJsonArray
in interface JsonObjectOrArray
-
isOfTypeJsonArrayNoKeyParsing
public boolean isOfTypeJsonArrayNoKeyParsing(String jsonPath)
-
isOfTypeJsonArray
public boolean isOfTypeJsonArray(String jsonPath,
boolean parseKey)
-
isNull
public boolean isNull(String jsonPath)
Description copied from interface: JsonObjectOrArray
Validates that the value at the specified JsonPath
exists and
is null
.
- Specified by:
isNull
in interface JsonObjectOrArray
-
isNullNoKeyParsing
public boolean isNullNoKeyParsing(String jsonPath)
-
validateIsNull
public boolean validateIsNull(String jsonPath,
boolean parseKey)
-
contains
public boolean contains(String jsonPath)
Description copied from interface: JsonObjectOrArray
Does the object contain an element at
the JsonPath
position (even if
null
)?
- Specified by:
contains
in interface JsonObjectOrArray
-
getElement
protected Object getElement(String key,
boolean hasdefaultElement,
Object defaultElement,
boolean parseJsonPath)
Gets the element at this key/jsonPath/index.
If the current object is immutable, the target element
may be cached.
-
clone
protected Object clone()
throws CloneNotSupportedException
- Overrides:
clone
in class Object
- Throws:
CloneNotSupportedException
-
getTrimTransformer
protected ElementTransformer getTrimTransformer()
-
trim
public void trim(String jsonPath)
Description copied from interface: JsonObjectOrArray
Trims the element at the specified JsonPath
if
it's of type String
.
- Specified by:
trim
in interface JsonObjectOrArray
-
trimAll
public void trimAll()
Description copied from interface: JsonObjectOrArray
Trims all the elements of the object that are of type
String
. This transformation is not recursive.
- Specified by:
trimAll
in interface JsonObjectOrArray
-
trimAll
public void trimAll(boolean recursive)
Description copied from interface: JsonObjectOrArray
Trims all the elements of the object that are of type
String.
- Specified by:
trimAll
in interface JsonObjectOrArray
- Parameters:
recursive
- if true
,
then all children elements will also be trimmed,
recursively.
-
transform
public void transform(String jsonPath,
ElementTransformer transformer)
Description copied from interface: JsonObjectOrArray
Transforms the element at the specified JsonPath
using
the transformer.
- Specified by:
transform
in interface JsonObjectOrArray
-
transformAll
public void transformAll(ElementTransformer transformer)
Description copied from interface: JsonObjectOrArray
Transforms all the elements of the object, using the specified
transformer. This transformation is not recursive.
- Specified by:
transformAll
in interface JsonObjectOrArray
-
set
public JsonObjectOrArray set(String jsonPath,
Object element)
Description copied from interface: JsonObjectOrArray
Sets an element at the specified JsonPath
.
Overwrites any existing element at that JsonPath
.
The required hierarchy will be created, if required, to
support the JsonPath
.
If the object to add is not of a JsonObject's native type,
the object is converted to a JsonObject or a
JsonArray before being added. Once the object is converted
and added, a modification to the original object won't
affect the added element, and vice-versa.
If the element to add is a JsonObject
or
a JsonArray
and is immutable then
it will be cloned.
Doing so, we can make sure that the current object is always
fully mutable or fully immutable.
If the element implements ToJsonObjectConvertible
, it
will be converted to a JsonObject
using the associated
conversion method. If it implements ToJsonArrayConvertible
, it
will be converted to a JsonArray
using the associated
conversion method.
Those are the types of object that will be converted to a
JsonArray instead of a JsonObject, if no conversion interface
is implemented :
-
A Collection
-
An array
- Specified by:
set
in interface JsonObjectOrArray
-
set
public JsonObjectOrArray set(String jsonPath,
Object element,
boolean clone)
Description copied from interface: JsonObjectOrArray
Sets an element at the specified JsonPath
.
Overwrites any existing element at that JsonPath
.
The required hierarchy will be created, if required, to
support the JsonPath
.
If the object to add is not of a JsonObject's native type,
the object is converted to a JsonObject or a
JsonArray before being added. Once the object is converted
and added, a modification to the original object won't
affect the added element, and vice-versa.
If the element to add is a JsonObject
or
a JsonArray
and is immutable then
it will be cloned.
Doing so, we can make sure that the current object is always
fully mutable or fully immutable.
If the element implements ToJsonObjectConvertible
, it
will be converted to a JsonObject
using the associated
conversion method. If it implements ToJsonArrayConvertible
, it
will be converted to a JsonArray
using the associated
conversion method.
Those are the types of object that will be converted to a
JsonArray instead of a JsonObject, if no conversion interface
is implemented :
-
A Collection
-
An array
- Specified by:
set
in interface JsonObjectOrArray
clone
- if true
, and the element to add is a
JsonObject
or JsonArray
, a clone will be made
before being added. If that case, any modification to the
original element won't affect the added one,
and vice-versa. If the element is immutable then it will
always be cloned. Doing so, we can make sure the current object is always
fully mutable or fully immutable.
-
put
protected JsonObjectOrArray put(String jsonPath,
Object element,
boolean clone,
boolean parseJsonPath)
-
putAsIs
protected abstract JsonObjectOrArray putAsIs(String key,
Object element)
-
transformAll
public abstract void transformAll(ElementTransformer transformer,
boolean recursive)
Description copied from interface: JsonObjectOrArray
Transforms all the elements of the object, using the specified
transformer.
- Specified by:
transformAll
in interface JsonObjectOrArray
recursive
- if true
,
then all children elements will also be transformed,
recursively.
-
clone
public abstract JsonObjectOrArray clone(boolean mutable)
Clone the object.
- Specified by:
clone
in interface JsonObjectOrArray
- Parameters:
mutable
- if true
the resulting
object and all its children will be mutable, otherwise
they will all be immutable.
Copyright © 2019. All rights reserved.