public.javadoc.org.spincast.core.json.JsonArrayDefault.html Maven / Gradle / Ivy
Show all versions of spincast-website Show documentation
JsonArrayDefault (org.spincast:spincast-framework 1.0.0 API)
org.spincast.core.json
Class JsonArrayDefault
- java.lang.Object
-
- org.spincast.core.json.JsonObjectArrayBase
-
- org.spincast.core.json.JsonArrayDefault
-
- All Implemented Interfaces:
- Iterable<Object>, JsonArray, JsonObjectOrArray
public class JsonArrayDefault
extends JsonObjectArrayBase
implements JsonArray
JsonArray
implementation.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.spincast.core.json.JsonObjectArrayBase
JsonObjectArrayBase.JsonPathCachingItem
-
Field Summary
Fields
Modifier and Type
Field and Description
protected org.slf4j.Logger
logger
-
Fields inherited from class org.spincast.core.json.JsonObjectArrayBase
defaultElementValidator
-
Constructor Summary
Constructors
Constructor and Description
JsonArrayDefault(JsonManager jsonManager,
SpincastUtils spincastUtils,
ObjectConverter objectConverter)
Constructor
JsonArrayDefault(List<Object> initialElements,
boolean mutable,
JsonManager jsonManager,
SpincastUtils spincastUtils,
ObjectConverter objectConverter)
Constructor
JsonArrayDefault(List<Object> initialElements,
JsonManager jsonManager,
SpincastUtils spincastUtils,
ObjectConverter objectConverter)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type
Method and Description
JsonArray
add(int index,
Object value)
Inserts an object at the specified index in the array.
JsonArray
add(int index,
Object value,
boolean clone)
Adds an object at the specified index.
JsonArray
add(Object value)
Adds an object at the end of the array.
JsonArray
add(Object value,
boolean clone)
Adds an object at the end of the array.
JsonArray
addAll(Collection<?> values)
Adds all elements at the end of the array.
JsonArray
addAll(Collection<?> values,
boolean clone)
Adds all elements at the end of the array.
JsonArray
addAll(JsonArray values)
Adds all elements at the end of the array.
JsonArray
addAll(JsonArray values,
boolean clone)
Adds elements at the end of the array.
JsonArray
addAll(Object[] values)
Adds all elements at the end of the array.
JsonArray
addAll(Object[] values,
boolean clone)
Adds elements at the end of the array.
protected JsonArray
addAsIs(Integer index,
Object value)
protected JsonArray
addAsIs(Object value)
JsonArray
clear()
Clears all elements.
JsonArray
clone(boolean mutable)
Clone the object.
List<Object>
convertToPlainList()
Converts the JsonArray
to a plain List<Object>
.
List<String>
convertToStringList()
Converts the JsonArray to a List<String>
.
protected <T> T
getArrayFirst(int index,
boolean hasDefaultValue,
T defaultValue,
JsonObjectDefault.IFirstElementGetter<T> firstElementGetter)
BigDecimal
getArrayFirstBigDecimal(int index)
Gets the first element (as BigDecimal) of a JsonArray
element.
BigDecimal
getArrayFirstBigDecimal(int index,
BigDecimal defaultValue)
Gets the first element (as BigDecimal) of a JsonArray
element.
Boolean
getArrayFirstBoolean(int index)
Gets the first element (as Boolean) of a JsonArray
element.
Boolean
getArrayFirstBoolean(int index,
Boolean defaultValue)
Gets the first element (as Boolean) of a JsonArray
element.
byte[]
getArrayFirstBytesFromBase64String(int index)
Gets the first element (as byte[]) of a JsonArray
element.
byte[]
getArrayFirstBytesFromBase64String(int index,
byte[] defaultValue)
Gets the first element (as byte[]) of a JsonArray
element.
Date
getArrayFirstDate(int index)
Gets the first element (as Date) of a JsonArray
element.
Date
getArrayFirstDate(int index,
Date defaultValue)
Gets the first element (as Date) of a JsonArray
element.
Double
getArrayFirstDouble(int index)
Gets the first element (as Double) of a JsonArray
element.
Double
getArrayFirstDouble(int index,
Double defaultValue)
Gets the first element (as Double) of a JsonArray
element.
Float
getArrayFirstFloat(int index)
Gets the first element (as Float) of a JsonArray
element.
Float
getArrayFirstFloat(int index,
Float defaultValue)
Gets the first element (as Float) of a JsonArray
element.
Instant
getArrayFirstInstant(int index)
Gets the first element (as Instant) of a JsonArray
element.
Instant
getArrayFirstInstant(int index,
Instant defaultValue)
Gets the first element (as Instant) of a JsonArray
element.
Integer
getArrayFirstInteger(int index)
Gets the first element (as Integer) of a JsonArray
element.
Integer
getArrayFirstInteger(int index,
Integer defaultValue)
Gets the first element (as Integer) of a JsonArray
element.
JsonArray
getArrayFirstJsonArray(int index)
Gets the first element (as JsonArray) of a JsonArray
element.
JsonArray
getArrayFirstJsonArray(int index,
JsonArray defaultValue)
Gets the first element (as JsonArray) of a JsonArray
element.
JsonObject
getArrayFirstJsonObject(int index)
Gets the first element (as JsonObject) of a JsonArray
element.
JsonObject
getArrayFirstJsonObject(int index,
JsonObject defaultValue)
Gets the first element (as JsonObject) of a JsonArray
element.
Long
getArrayFirstLong(int index)
Gets the first element (as Long) of a JsonArray
element.
Long
getArrayFirstLong(int index,
Long defaultValue)
Gets the first element (as Long) of a JsonArray
element.
String
getArrayFirstString(int index)
Gets the first element (as String) of a JsonArray
element.
String
getArrayFirstString(int index,
String defaultValue)
Gets the first element (as String) of a JsonArray
element.
BigDecimal
getBigDecimal(int index)
Gets an element as BigDecimal
.
BigDecimal
getBigDecimal(int index,
BigDecimal defaultValue)
Gets an element as BigDecimal
.
Boolean
getBoolean(int index)
Gets an element as Boolean
.
Boolean
getBoolean(int index,
Boolean defaultValue)
Gets an element as Boolean
.
byte[]
getBytesFromBase64String(int index)
Gets a byte array, from a base 64 encoded element.
byte[]
getBytesFromBase64String(int index,
byte[] defaultValue)
Gets a byte array, from a base 64 encoded element.
Date
getDate(int index)
Gets a UTC timezoned date from a ISO 8601
date element.
Date
getDate(int index,
Date defaultValue)
Gets a UTC timezoned date from a ISO 8601
date element.
Double
getDouble(int index)
Gets an element as Double
.
Double
getDouble(int index,
Double defaultValue)
Gets an element as Double
.
protected Object
getElement(int index)
protected Object
getElementNoKeyParsing(String jsonPath,
boolean hasDefaultValue,
Object defaultValue)
Gets the element at this key/index, without
key parsing.
protected List<Object>
getElements()
Float
getFloat(int index)
Gets an element as Float
.
Float
getFloat(int index,
Float defaultValue)
Gets an element as Float
.
Instant
getInstant(int index)
Gets an Instant from a ISO 8601
date element.
Instant
getInstant(int index,
Instant defaultValue)
Gets an Instant from a ISO 8601
date element.
Integer
getInteger(int index)
Gets an element as Integer
.
Integer
getInteger(int index,
Integer defaultValue)
Gets an element as Integer
.
JsonArray
getJsonArray(int index)
Gets an element as JsonArray
.
JsonArray
getJsonArray(int index,
JsonArray defaultValue)
Gets an element as JsonArray
.
JsonArray
getJsonArrayOrEmpty(int index)
Gets an element as JsonArray
.
JsonObject
getJsonObject(int index)
Gets an element as JsonObject
.
JsonObject
getJsonObject(int index,
JsonObject defaultValue)
Gets an element as JsonObject
.
JsonObject
getJsonObjectOrEmpty(int index)
Gets an element as JsonObject
.
Long
getLong(int index)
Gets an element as Long
.
Long
getLong(int index,
Long defaultValue)
Gets an element as Long
.
Object
getObject(int index)
Gets an element, untyped.
Object
getObject(int index,
Object defaultValue)
Gets an element, untyped.
String
getString(int index)
Gets an element as String
.
String
getString(int index,
String defaultValue)
Gets an element as String
.
boolean
isCanBeConvertedToBigDecimal(int index)
Validates that the element at the specified index
exists and
is currently null
, of type BigDecimal
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToBoolean(int index)
Validates that the element at the specified index
exists and
is currently null
, of type Boolean
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToByteArray(int index)
Validates that the element at the specified index
exists and
is currently null
, of type base 64 String
representing
a byte array, or can be converted and retrieved as one.
boolean
isCanBeConvertedToDate(int index)
Validates that the element at the specified index
exists and
is currently null
, of type Date
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToDouble(int index)
Validates that the element at the specified index
exists and
is currently null
, of type Double
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToFloat(int index)
Validates that the element at the specified index
exists and
is currently null
, of type Float
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToInteger(int index)
Validates that the element at the specified index
exists and
is currently null
, of type Integer
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToJsonArray(int index)
Validates that the element at the specified index
exists and
is currently null
, of type JsonArray
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToJsonObject(int index)
Validates that the element at the specified index
exists and
is currently null
, of type JsonObject
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToLong(int index)
Validates that the element at the specified index
exists and
is currently null
, of type Long
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToString(int index)
Validates that the element at the specified index
exists and
is currently null
, of type String
, or can be
converted and retrieved as one.
boolean
isElementExists(int index)
Is there an element at the specified index? This returns
true
even if the element is null
.
boolean
isEquivalentTo(JsonArray other)
Compares the current JsonArray
to the specified one
and returns true
if they are equivalent.
boolean
isNull(int index)
Validates that there is an element at the specified index
and
it is null
.
boolean
isOfTypeBigDecimal(int index)
Validates that the element at the specified index
exists and
is currently null
or of type BigDecimal
, without requiring
any conversion.
boolean
isOfTypeBoolean(int index)
Validates that the element at the specified index
exists and
is currently null
or of type Boolean
, without requiring
any conversion.
boolean
isOfTypeByteArray(int index,
boolean acceptBase64StringToo)
Validates that the element at the specified JsonPath
exists and
is currently null
or of type byte[]
, without requiring
any conversion.
boolean
isOfTypeDate(int index)
Validates that the element at the specified index
exists and
is currently null
or of type Date
, without requiring
any conversion.
boolean
isOfTypeDouble(int index)
Validates that the element at the specified index
exists and
is currently null
or of type Double
, without requiring
any conversion.
boolean
isOfTypeFloat(int index)
Validates that the element at the specified index
exists and
is currently null
or of type Float
, without requiring
any conversion.
boolean
isOfTypeInteger(int index)
Validates that the element at the specified index
exists and
is currently null
or of type Integer
, without requiring
any conversion.
boolean
isOfTypeJsonArray(int index)
Validates that the element at the specified index
exists and
is currently null
or of type JsonArray
, without requiring
any conversion.
boolean
isOfTypeJsonObject(int index)
Validates that the element at the specified index
exists and
is currently null
or of type JsonObject
, without requiring
any conversion.
boolean
isOfTypeLong(int index)
Validates that the element at the specified index
exists and
is currently null
or of type Long
, without requiring
any conversion.
boolean
isOfTypeString(int index)
Validates that the element at the specified index
exists and
is currently null
or of type String
, without requiring
any conversion.
Iterator<Object>
iterator()
protected JsonArray
putAsIs(String key,
Object value)
JsonArray
remove(int index)
Removes an element at the specified index.
JsonArray
remove(String jsonPath)
Removes an element at JsonPath
.
JsonArray
set(int index,
Object value)
Sets an object at the specified index.
JsonArray
set(int index,
Object value,
boolean clone)
Sets an object at the specified index.
JsonArray
setOrAdd(Integer index,
Object value,
boolean clone,
boolean insert)
protected JsonArray
setOrAddAsIs(Integer index,
Object value,
boolean insert)
int
size()
The size of the object.
void
transform(int index,
ElementTransformer transformer)
Transforms the element at the given index, using the
specified ElementTransformer
.
void
transformAll(ElementTransformer transformer,
boolean recursive)
Transforms all the elements of the object, using the specified
transformer.
void
trim(int index)
Trims the element, if it's of type String
.
-
Methods inherited from class org.spincast.core.json.JsonObjectArrayBase
clone, contains, getArrayFirst, getArrayFirstBigDecimal, getArrayFirstBigDecimal, getArrayFirstBigDecimal, getArrayFirstBigDecimalNoKeyParsing, getArrayFirstBigDecimalNoKeyParsing, getArrayFirstBoolean, getArrayFirstBoolean, getArrayFirstBoolean, getArrayFirstBooleanNoKeyParsing, getArrayFirstBooleanNoKeyParsing, getArrayFirstBytesFromBase64String, getArrayFirstBytesFromBase64String, getArrayFirstBytesFromBase64String, getArrayFirstBytesFromBase64StringNoKeyParsing, getArrayFirstBytesFromBase64StringNoKeyParsing, getArrayFirstDate, getArrayFirstDate, getArrayFirstDate, getArrayFirstDateNoKeyParsing, getArrayFirstDateNoKeyParsing, getArrayFirstDouble, getArrayFirstDouble, getArrayFirstDouble, getArrayFirstDoubleNoKeyParsing, getArrayFirstDoubleNoKeyParsing, getArrayFirstFloat, getArrayFirstFloat, getArrayFirstFloat, getArrayFirstFloatNoKeyParsing, getArrayFirstFloatNoKeyParsing, getArrayFirstInstant, getArrayFirstInstant, getArrayFirstInstant, getArrayFirstInstantNoKeyParsing, getArrayFirstInstantNoKeyParsing, getArrayFirstInteger, getArrayFirstInteger, getArrayFirstInteger, getArrayFirstIntegerNoKeyParsing, getArrayFirstIntegerNoKeyParsing, getArrayFirstJsonArray, getArrayFirstJsonArray, getArrayFirstJsonArray, getArrayFirstJsonArrayNoKeyParsing, getArrayFirstJsonArrayNoKeyParsing, getArrayFirstJsonObject, getArrayFirstJsonObject, getArrayFirstJsonObject, getArrayFirstJsonObjectNoKeyParsing, getArrayFirstJsonObjectNoKeyParsing, getArrayFirstLong, getArrayFirstLong, getArrayFirstLong, getArrayFirstLongNoKeyParsing, getArrayFirstLongNoKeyParsing, getArrayFirstString, getArrayFirstString, getArrayFirstString, getArrayFirstStringNoKeyParsing, getArrayFirstStringNoKeyParsing, getBigDecimal, getBigDecimal, getBigDecimal, getBigDecimalElement, getBigDecimalFromObject, getBigDecimalNoKeyParsing, getBigDecimalNoKeyParsing, getBoolean, getBoolean, getBoolean, getBooleanElement, getBooleanFromObject, getBooleanNoKeyParsing, getBooleanNoKeyParsing, getBytesFromBase64String, getBytesFromBase64String, getBytesFromBase64String, getBytesFromBase64StringElement, getBytesFromBase64StringNoKeyParsing, getBytesFromBase64StringNoKeyParsing, getBytesFromBase64StringValueFromObject, getDate, getDate, getDate, getDateElement, getDateFromObject, getDateNoKeyParsing, getDateNoKeyParsing, getdefaultElementValidator, getDouble, getDouble, getDouble, getDoubleElement, getDoubleFromObject, getDoubleNoKeyParsing, getDoubleNoKeyParsing, getElement, getFloat, getFloat, getFloat, getFloatElement, getFloatFromObject, getFloatNoKeyParsing, getFloatNoKeyParsing, getInstant, getInstant, getInstant, getInstantElement, getInstantFromObject, getInstantNoKeyParsing, getInstantNoKeyParsing, getInteger, getInteger, getInteger, getIntegerElement, getIntegerFromObject, getIntegerNoKeyParsing, getIntegerNoKeyParsing, getJsonArray, getJsonArray, getJsonArray, getJsonArrayFromObject, getJsonArrayNoKeyParsing, getJsonArrayNoKeyParsing, getJsonArrayOrEmpty, getJsonArrayOrEmpty, getJsonArrayOrEmptyNoKeyParsing, getJsonManager, getJsonObject, getJsonObject, getJsonObject, getJsonObject, getJsonObjectFromObject, getJsonObjectNoKeyParsing, getJsonObjectNoKeyParsing, getJsonObjectOrEmpty, getJsonObjectOrEmpty, getJsonObjectOrEmptyNoKeyParsing, getJsonPathCachingMap, getLong, getLong, getLong, getLongElement, getLongFromObject, getLongNoKeyParsing, getLongNoKeyParsing, getObject, getObject, getObject, getObjectConverter, getObjectNoKeyParsing, getObjectNoKeyParsing, getSpincastUtils, getString, getString, getString, getString, getStringFromObject, getStringNoKeyParsing, getStringNoKeyParsing, getTrimTransformer, isCanBeConvertedToBigDecimal, isCanBeConvertedToBigDecimal, isCanBeConvertedToBigDecimalNoKeyParsing, isCanBeConvertedToBoolean, isCanBeConvertedToBoolean, isCanBeConvertedToBooleanNoKeyParsing, isCanBeConvertedToByteArray, isCanBeConvertedToByteArray, isCanBeConvertedToByteArrayNoKeyParsing, isCanBeConvertedToDate, isCanBeConvertedToDate, isCanBeConvertedToDateNoKeyParsing, isCanBeConvertedToDouble, isCanBeConvertedToDouble, isCanBeConvertedToDoubleNoKeyParsing, isCanBeConvertedToFloat, isCanBeConvertedToFloat, isCanBeConvertedToFloatNoKeyParsing, isCanBeConvertedToInteger, isCanBeConvertedToInteger, isCanBeConvertedToIntegerNoKeyParsing, isCanBeConvertedToJsonArray, isCanBeConvertedToJsonArray, isCanBeConvertedToJsonArrayNoKeyParsing, isCanBeConvertedToJsonObject, isCanBeConvertedToJsonObject, isCanBeConvertedToJsonObjectNoKeyParsing, isCanBeConvertedToLong, isCanBeConvertedToLong, isCanBeConvertedToLongNoKeyParsing, isCanBeConvertedToString, isCanBeConvertedToString, isCanBeConvertedToStringNoKeyParsing, isMutable, isNull, isNullNoKeyParsing, isOfTypeBigDecimal, isOfTypeBigDecimalNoKeyParsing, isOfTypeBoolean, isOfTypeBoolean, isOfTypeBooleanNoKeyParsing, isOfTypeByteArray, isOfTypeByteArray, isOfTypeByteArrayNoKeyParsing, isOfTypeDate, isOfTypeDate, isOfTypeDateNoKeyParsing, isOfTypeDouble, isOfTypeDouble, isOfTypeDoubleNoKeyParsing, isOfTypeeBigDecimal, isOfTypeFloat, isOfTypeFloat, isOfTypeFloatNoKeyParsing, isOfTypeInteger, isOfTypeInteger, isOfTypeIntegerNoKeyParsing, isOfTypeJsonArray, isOfTypeJsonArray, isOfTypeJsonArrayNoKeyParsing, isOfTypeJsonObject, isOfTypeJsonObject, isOfTypeJsonObjectNoKeyParsing, isOfTypeLong, isOfTypeLong, isOfTypeLongNoKeyParsing, isOfTypeString, isOfTypeString, isOfTypeStringNoKeyParsing, put, set, set, toJsonString, toJsonString, toString, transform, transformAll, trim, trimAll, trimAll, validateIsNull
-
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
contains, getArrayFirstBigDecimal, getArrayFirstBigDecimal, getArrayFirstBoolean, getArrayFirstBoolean, getArrayFirstBytesFromBase64String, getArrayFirstBytesFromBase64String, getArrayFirstDate, getArrayFirstDate, getArrayFirstDouble, getArrayFirstDouble, getArrayFirstFloat, getArrayFirstFloat, getArrayFirstInstant, getArrayFirstInstant, getArrayFirstInteger, getArrayFirstInteger, getArrayFirstJsonArray, getArrayFirstJsonArray, getArrayFirstJsonObject, getArrayFirstJsonObject, getArrayFirstLong, getArrayFirstLong, getArrayFirstString, getArrayFirstString, getBigDecimal, getBigDecimal, getBoolean, getBoolean, getBytesFromBase64String, getBytesFromBase64String, getDate, getDate, getDouble, getDouble, getFloat, getFloat, getInstant, getInstant, getInteger, getInteger, getJsonArray, getJsonArray, getJsonArrayOrEmpty, getJsonArrayOrEmpty, getJsonObject, getJsonObject, getJsonObjectOrEmpty, getJsonObjectOrEmpty, getLong, getLong, getObject, getObject, getString, getString, isCanBeConvertedToBigDecimal, isCanBeConvertedToBoolean, isCanBeConvertedToByteArray, isCanBeConvertedToDate, isCanBeConvertedToDouble, isCanBeConvertedToFloat, isCanBeConvertedToInteger, isCanBeConvertedToJsonArray, isCanBeConvertedToJsonObject, isCanBeConvertedToLong, isCanBeConvertedToString, isMutable, isNull, isOfTypeBigDecimal, isOfTypeBoolean, isOfTypeByteArray, isOfTypeDate, isOfTypeDouble, isOfTypeFloat, isOfTypeInteger, isOfTypeJsonArray, isOfTypeJsonObject, isOfTypeLong, isOfTypeString, set, set, toJsonString, toJsonString, transform, transformAll, trim, trimAll, trimAll
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
Constructor Detail
-
JsonArrayDefault
public JsonArrayDefault(JsonManager jsonManager,
SpincastUtils spincastUtils,
ObjectConverter objectConverter)
Constructor
-
JsonArrayDefault
public JsonArrayDefault(@Nullable
List<Object> initialElements,
JsonManager jsonManager,
SpincastUtils spincastUtils,
ObjectConverter objectConverter)
Constructor
-
JsonArrayDefault
public JsonArrayDefault(@Nullable
List<Object> initialElements,
boolean mutable,
JsonManager jsonManager,
SpincastUtils spincastUtils,
ObjectConverter objectConverter)
Constructor
-
Method Detail
-
getElement
protected Object getElement(int index)
-
add
public JsonArray add(Object value)
Description copied from interface: JsonArray
Adds an object at the end of the array.
If the object to add is not of a native type,
then the object is converted before being added.
Once the object is converted and added, a modification of the original
object won't affect this element, and vice-versa.
If the element to add is a JsonObject
or
a JsonArray
and is immutable, it will be cloned.
Doing so, we can make sure the JsonArray
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 an JsonArray
using the associated
conversion method.
Those are the types of objects that will be converted to a
JsonArray
instead of a JsonObject
, if
no conversion interface is implemented :
-
A Collection
-
An array
-
add
public JsonArray add(int index,
Object value)
Description copied from interface: JsonArray
Inserts an object at the specified index in the array.
Any existing elements starting at this index are
pushed to the right.
If the specified index is greater than the current
end of the array, null
elements are
added to fill up positionss up to the specified index!
Use set
instead if you want
to replace the element at the specified index.
If the object to add is not of a native type,
then the object is converted before being added.
Once the object is converted and added, a modification of the original
object won't affect this element, and vice-versa.
If the element to add is a JsonObject
or
a JsonArray
and is immutable, it will be cloned.
Doing so, we can make sure the JsonArray
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 an JsonArray
using the associated
conversion method.
Those are the types of objects that will be converted to a
JsonArray
instead of a JsonObject
, if
no conversion interface is implemented :
-
A Collection
-
An array
-
add
public JsonArray add(Object value,
boolean clone)
Description copied from interface: JsonArray
Adds an object at the end of the array.
If the object to add is not of a native type,
then the object is converted before being added.
Once the object is converted and added, a modification of the original
object won't affect this element, and vice-versa.
If the element to add is a JsonObject
or
a JsonArray
and is immutable, it will be cloned.
Doing so, we can make sure the JsonArray
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 an JsonArray
using the associated
conversion method.
Those are the types of objects that will be converted to a
JsonArray
instead of a JsonObject
, if
no conversion interface is implemented :
-
A Collection
-
An array
- Specified by:
add
in interface JsonArray
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 a
JsonArray
is always
fully mutable or fully immutable.
-
add
public JsonArray add(int index,
Object value,
boolean clone)
Description copied from interface: JsonArray
Adds an object at the specified index.
Any existing elements starting at this index are
pushed to the right.
If the specified index is greater than the current
end of the array, null
elements are
added to fill positions up to the specified index!
Use set
instead if you want
to replace the element at the specified index.
If the object to add is not of a native type,
then the object is converted before being added.
Once the object is converted and added, a modification of the original
object won't affect this element, and vice-versa.
If the element to add is a JsonObject
or
a JsonArray
and is immutable, it will be cloned.
Doing so, we can make sure the JsonArray
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 an JsonArray
using the associated
conversion method.
Those are the types of objects that will be converted to a
JsonArray
instead of a JsonObject
, if
no conversion interface is implemented :
-
A Collection
-
An array
- Specified by:
add
in interface JsonArray
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 a
JsonArray
is always
fully mutable or fully immutable.
-
addAll
public JsonArray addAll(Collection<?> values)
Description copied from interface: JsonArray
Adds all elements at the end of the array.
If an element to add is not of a native type,
then the element is converted before being added.
Once the element is converted and added, a modification of the original
object won't affect this element, and vice-versa.
If an element to add is a JsonObject
or
a JsonArray
and is immutable, it will be cloned.
Doing so, we can make sure the JsonArray
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 an JsonArray
using the associated
conversion method.
Those are the types of objects that will be converted to a
JsonArray
instead of a JsonObject
, if
no conversion interface is implemented :
-
A Collection
-
An array
-
addAll
public JsonArray addAll(Collection<?> values,
boolean clone)
Description copied from interface: JsonArray
Adds all elements at the end of the array.
If an element to add is not of a native type,
then the element is converted before being added.
Once the element is converted and added, a modification of the original
object won't affect this element, and vice-versa.
If an element to add is a JsonObject
or
a JsonArray
and is immutable, it will be cloned.
Doing so, we can make sure the JsonArray
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 an JsonArray
using the associated
conversion method.
Those are the types of objects that will be converted to a
JsonArray
instead of a JsonObject
, if
no conversion interface is implemented :
-
A Collection
-
An array
- Specified by:
addAll
in interface JsonArray
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 a
JsonArray
is always
fully mutable or fully immutable.
-
addAll
public JsonArray addAll(Object[] values)
Description copied from interface: JsonArray
Adds all elements at the end of the array.
If an element to add is not of a native type,
then the element is converted before being added.
Once the element is converted and added, a modification of the original
object won't affect this element, and vice-versa.
If an element to add is a JsonObject
or
a JsonArray
and is immutable, it will be cloned.
Doing so, we can make sure the JsonArray
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 an JsonArray
using the associated
conversion method.
Those are the types of objects that will be converted to a
JsonArray
instead of a JsonObject
, if
no conversion interface is implemented :
-
A Collection
-
An array
-
addAll
public JsonArray addAll(Object[] values,
boolean clone)
Description copied from interface: JsonArray
Adds elements at the end of the array.
If an element to add is not of a native type,
then the element is converted before being added.
Once the element is converted and added, a modification of the original
object won't affect this element, and vice-versa.
If an element to add is a JsonObject
or
a JsonArray
and is immutable, it will be cloned.
Doing so, we can make sure the JsonArray
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 an JsonArray
using the associated
conversion method.
Those are the types of objects that will be converted to a
JsonArray
instead of a JsonObject
, if
no conversion interface is implemented :
-
A Collection
-
An array
- Specified by:
addAll
in interface JsonArray
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 a
JsonArray
is always
fully mutable or fully immutable.
-
addAll
public JsonArray addAll(JsonArray values)
Description copied from interface: JsonArray
Adds all elements at the end of the array.
If an element to add is not of a native type,
then the element is converted before being added.
Once the element is converted and added, a modification of the original
object won't affect this element, and vice-versa.
If an element to add is a JsonObject
or
a JsonArray
and is immutable, it will be cloned.
Doing so, we can make sure the JsonArray
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 an JsonArray
using the associated
conversion method.
Those are the types of objects that will be converted to a
JsonArray
instead of a JsonObject
, if
no conversion interface is implemented :
-
A Collection
-
An array
-
addAll
public JsonArray addAll(JsonArray values,
boolean clone)
Description copied from interface: JsonArray
Adds elements at the end of the array.
If an element to add is not of a native type,
then the element is converted before being added.
Once the element is converted and added, a modification of the original
object won't affect this element, and vice-versa.
If an element to add is a JsonObject
or
a JsonArray
and is immutable, it will be cloned.
Doing so, we can make sure the JsonArray
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 an JsonArray
using the associated
conversion method.
Those are the types of objects that will be converted to a
JsonArray
instead of a JsonObject
, if
no conversion interface is implemented :
-
A Collection
-
An array
- Specified by:
addAll
in interface JsonArray
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 a
JsonArray
is always
fully mutable or fully immutable.
-
set
public JsonArray set(int index,
Object value)
Description copied from interface: JsonArray
Sets an object at the specified index.
If there is an element at this index, it is
overwritten.
If the specified index is greater than the current
end of the array, null
elements are
added to fill positions up to the specified index.
Use add
instead if you want
to insert the element at the specified index without
overwritting any existing element.
If an element to add is not of a native type,
then the element is converted before being added.
Once the element is converted and added, a modification of the original
object won't affect this element, and vice-versa.
If an element to add is a JsonObject
or
a JsonArray
and is immutable, it will be cloned.
Doing so, we can make sure the JsonArray
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 an JsonArray
using the associated
conversion method.
Those are the types of objects that will be converted to a
JsonArray
instead of a JsonObject
, if
no conversion interface is implemented :
-
A Collection
-
An array
-
set
public JsonArray set(int index,
Object value,
boolean clone)
Description copied from interface: JsonArray
Sets an object at the specified index.
If there is an element at this index, it is
overwritten.
If the specified index is greater than the current
end of the array, null
elements are
added to fill positions up to the specified index.
Use add
instead if you want
to insert the element at the specified index without
overwritting any existing element.
If an element to add is not of a native type,
then the element is converted before being added.
Once the element is converted and added, a modification of the original
object won't affect this element, and vice-versa.
If an element to add is a JsonObject
or
a JsonArray
and is immutable, it will be cloned.
Doing so, we can make sure the JsonArray
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 an JsonArray
using the associated
conversion method.
Those are the types of objects 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 JsonArray
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 a
JsonArray
is always
fully mutable or fully immutable.
-
remove
public JsonArray remove(String jsonPath)
Description copied from interface: JsonObjectOrArray
Removes an element at JsonPath
.
- Specified by:
remove
in interface JsonObjectOrArray
- Returns:
- the current object (fluent style).
-
remove
public JsonArray remove(int index)
Description copied from interface: JsonArray
Removes an element at the specified index.
Any elements to the right are shift to the left.
If the index is invalid, nothing is done.
-
clear
public JsonArray clear()
Description copied from interface: JsonObjectOrArray
Clears all elements.
- Specified by:
clear
in interface JsonObjectOrArray
-
size
public int size()
Description copied from interface: JsonObjectOrArray
The size of the object.
- Specified by:
size
in interface JsonObjectOrArray
-
isElementExists
public boolean isElementExists(int index)
Description copied from interface: JsonArray
Is there an element at the specified index? This returns
true
even if the element is null
.
This is a synonym of index >= 0 && index < size()
- Specified by:
isElementExists
in interface JsonArray
-
convertToStringList
public List<String> convertToStringList()
Description copied from interface: JsonArray
Converts the JsonArray to a List<String>
.
To do so, the toString()
method will be called
on any non null element.
This list is always a new instance and is mutable.
- Specified by:
convertToStringList
in interface JsonArray
-
getJsonObject
public JsonObject getJsonObject(int index)
Description copied from interface: JsonArray
Gets an element as JsonObject
.
- Specified by:
getJsonObject
in interface JsonArray
- Returns:
- the element or
null
if not found.
-
getJsonObject
public JsonObject getJsonObject(int index,
JsonObject defaultValue)
Description copied from interface: JsonArray
Gets an element as JsonObject
.
- Specified by:
getJsonObject
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if not found.
-
getJsonObjectOrEmpty
public JsonObject getJsonObjectOrEmpty(int index)
Description copied from interface: JsonArray
Gets an element as JsonObject
.
- Specified by:
getJsonObjectOrEmpty
in interface JsonArray
- Returns:
- the element or an empty
JsonObject
if not found
or if null
.
-
getJsonArray
public JsonArray getJsonArray(int index)
Description copied from interface: JsonArray
Gets an element as JsonArray
.
- Specified by:
getJsonArray
in interface JsonArray
- Returns:
- the element or
null
if not found.
-
getJsonArray
public JsonArray getJsonArray(int index,
JsonArray defaultValue)
Description copied from interface: JsonArray
Gets an element as JsonArray
.
- Specified by:
getJsonArray
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if not found.
-
getJsonArrayOrEmpty
public JsonArray getJsonArrayOrEmpty(int index)
Description copied from interface: JsonArray
Gets an element as JsonArray
.
- Specified by:
getJsonArrayOrEmpty
in interface JsonArray
- Returns:
- the element or an empty
JsonArray
if not found or if null
.
-
getString
public String getString(int index)
Description copied from interface: JsonArray
Gets an element as String
.
-
getString
public String getString(int index,
String defaultValue)
Description copied from interface: JsonArray
Gets an element as String
.
-
getInteger
public Integer getInteger(int index)
Description copied from interface: JsonArray
Gets an element as Integer
.
- Specified by:
getInteger
in interface JsonArray
- Returns:
- the element or
null
if not found.
-
getInteger
public Integer getInteger(int index,
Integer defaultValue)
Description copied from interface: JsonArray
Gets an element as Integer
.
- Specified by:
getInteger
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if not found.
-
getLong
public Long getLong(int index)
Description copied from interface: JsonArray
Gets an element as Long
.
-
getLong
public Long getLong(int index,
Long defaultValue)
Description copied from interface: JsonArray
Gets an element as Long
.
-
getDouble
public Double getDouble(int index)
Description copied from interface: JsonArray
Gets an element as Double
.
-
getDouble
public Double getDouble(int index,
Double defaultValue)
Description copied from interface: JsonArray
Gets an element as Double
.
-
getFloat
public Float getFloat(int index)
Description copied from interface: JsonArray
Gets an element as Float
.
-
getFloat
public Float getFloat(int index,
Float defaultValue)
Description copied from interface: JsonArray
Gets an element as Float
.
-
getBoolean
public Boolean getBoolean(int index)
Description copied from interface: JsonArray
Gets an element as Boolean
.
- Specified by:
getBoolean
in interface JsonArray
- Returns:
- the element or
null
if not found.
-
getBoolean
public Boolean getBoolean(int index,
Boolean defaultValue)
Description copied from interface: JsonArray
Gets an element as Boolean
.
- Specified by:
getBoolean
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if not found.
-
getBigDecimal
public BigDecimal getBigDecimal(int index)
Description copied from interface: JsonArray
Gets an element as BigDecimal
.
- Specified by:
getBigDecimal
in interface JsonArray
- Returns:
- the element or
null
if not found.
-
getBigDecimal
public BigDecimal getBigDecimal(int index,
BigDecimal defaultValue)
Description copied from interface: JsonArray
Gets an element as BigDecimal
.
- Specified by:
getBigDecimal
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if not found.
-
getBytesFromBase64String
public byte[] getBytesFromBase64String(int index)
Description copied from interface: JsonArray
Gets a byte array, from a base 64 encoded element.
- Specified by:
getBytesFromBase64String
in interface JsonArray
- Returns:
- the element or
null
if not found.
-
getBytesFromBase64String
public byte[] getBytesFromBase64String(int index,
byte[] defaultValue)
Description copied from interface: JsonArray
Gets a byte array, from a base 64 encoded element.
- Specified by:
getBytesFromBase64String
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if not found.
-
getDate
public Date getDate(int index)
Description copied from interface: JsonArray
Gets a UTC timezoned date from a ISO 8601
date element.
-
getDate
public Date getDate(int index,
Date defaultValue)
Description copied from interface: JsonArray
Gets a UTC timezoned date from a ISO 8601
date element.
-
getInstant
public Instant getInstant(int index)
Description copied from interface: JsonArray
Gets an Instant from a ISO 8601
date element.
- Specified by:
getInstant
in interface JsonArray
- Returns:
- the element or
null
if not found.
-
getInstant
public Instant getInstant(int index,
Instant defaultValue)
Description copied from interface: JsonArray
Gets an Instant from a ISO 8601
date element.
- Specified by:
getInstant
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if not found.
-
getObject
public Object getObject(int index)
Description copied from interface: JsonArray
Gets an element, untyped.
-
getObject
public Object getObject(int index,
Object defaultValue)
Description copied from interface: JsonArray
Gets an element, untyped.
-
getElementNoKeyParsing
protected Object getElementNoKeyParsing(String jsonPath,
boolean hasDefaultValue,
Object defaultValue)
Description copied from class: JsonObjectArrayBase
Gets the element at this key/index, without
key parsing.
- Specified by:
getElementNoKeyParsing
in class JsonObjectArrayBase
-
getArrayFirst
protected <T> T getArrayFirst(int index,
boolean hasDefaultValue,
T defaultValue,
JsonObjectDefault.IFirstElementGetter<T> firstElementGetter)
-
getArrayFirstJsonObject
public JsonObject getArrayFirstJsonObject(int index)
Description copied from interface: JsonArray
Gets the first element (as JsonObject) of a JsonArray
element.
- Specified by:
getArrayFirstJsonObject
in interface JsonArray
- Returns:
- the element or
null
if the array or
the first element are not found.
-
getArrayFirstJsonObject
public JsonObject getArrayFirstJsonObject(int index,
JsonObject defaultValue)
Description copied from interface: JsonArray
Gets the first element (as JsonObject) of a JsonArray
element.
- Specified by:
getArrayFirstJsonObject
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if the array or
the first element are not found.
-
getArrayFirstJsonArray
public JsonArray getArrayFirstJsonArray(int index)
Description copied from interface: JsonArray
Gets the first element (as JsonArray) of a JsonArray
element.
- Specified by:
getArrayFirstJsonArray
in interface JsonArray
- Returns:
- the element or
null
if the array or
the first element are not found.
-
getArrayFirstJsonArray
public JsonArray getArrayFirstJsonArray(int index,
JsonArray defaultValue)
Description copied from interface: JsonArray
Gets the first element (as JsonArray) of a JsonArray
element.
- Specified by:
getArrayFirstJsonArray
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if the array or
the first element are not found.
-
getArrayFirstString
public String getArrayFirstString(int index)
Description copied from interface: JsonArray
Gets the first element (as String) of a JsonArray
element.
- Specified by:
getArrayFirstString
in interface JsonArray
- Returns:
- the element or
null
if the array or
the first element are not found.
-
getArrayFirstString
public String getArrayFirstString(int index,
String defaultValue)
Description copied from interface: JsonArray
Gets the first element (as String) of a JsonArray
element.
- Specified by:
getArrayFirstString
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if the array or
the first element are not found.
-
getArrayFirstInteger
public Integer getArrayFirstInteger(int index)
Description copied from interface: JsonArray
Gets the first element (as Integer) of a JsonArray
element.
- Specified by:
getArrayFirstInteger
in interface JsonArray
- Returns:
- the element or
null
if the array or
the first element are not found.
-
getArrayFirstInteger
public Integer getArrayFirstInteger(int index,
Integer defaultValue)
Description copied from interface: JsonArray
Gets the first element (as Integer) of a JsonArray
element.
- Specified by:
getArrayFirstInteger
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if the array or
the first element are not found.
-
getArrayFirstLong
public Long getArrayFirstLong(int index)
Description copied from interface: JsonArray
Gets the first element (as Long) of a JsonArray
element.
- Specified by:
getArrayFirstLong
in interface JsonArray
- Returns:
- the element or
null
if the array or
the first element are not found.
-
getArrayFirstLong
public Long getArrayFirstLong(int index,
Long defaultValue)
Description copied from interface: JsonArray
Gets the first element (as Long) of a JsonArray
element.
- Specified by:
getArrayFirstLong
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if the array or
the first element are not found.
-
getArrayFirstDouble
public Double getArrayFirstDouble(int index)
Description copied from interface: JsonArray
Gets the first element (as Double) of a JsonArray
element.
- Specified by:
getArrayFirstDouble
in interface JsonArray
- Returns:
- the element or
null
if the array or
the first element are not found.
-
getArrayFirstDouble
public Double getArrayFirstDouble(int index,
Double defaultValue)
Description copied from interface: JsonArray
Gets the first element (as Double) of a JsonArray
element.
- Specified by:
getArrayFirstDouble
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if the array or
the first element are not found.
-
getArrayFirstFloat
public Float getArrayFirstFloat(int index)
Description copied from interface: JsonArray
Gets the first element (as Float) of a JsonArray
element.
- Specified by:
getArrayFirstFloat
in interface JsonArray
- Returns:
- the element or
null
if the array or
the first element are not found.
-
getArrayFirstFloat
public Float getArrayFirstFloat(int index,
Float defaultValue)
Description copied from interface: JsonArray
Gets the first element (as Float) of a JsonArray
element.
- Specified by:
getArrayFirstFloat
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if the array or
the first element are not found.
-
getArrayFirstBoolean
public Boolean getArrayFirstBoolean(int index)
Description copied from interface: JsonArray
Gets the first element (as Boolean) of a JsonArray
element.
- Specified by:
getArrayFirstBoolean
in interface JsonArray
- Returns:
- the element or
null
if the array or
the first element are not found.
-
getArrayFirstBoolean
public Boolean getArrayFirstBoolean(int index,
Boolean defaultValue)
Description copied from interface: JsonArray
Gets the first element (as Boolean) of a JsonArray
element.
- Specified by:
getArrayFirstBoolean
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if the array or
the first element are not found.
-
getArrayFirstBigDecimal
public BigDecimal getArrayFirstBigDecimal(int index)
Description copied from interface: JsonArray
Gets the first element (as BigDecimal) of a JsonArray
element.
- Specified by:
getArrayFirstBigDecimal
in interface JsonArray
- Returns:
- the element or
null
if the array or
the first element are not found.
-
getArrayFirstBigDecimal
public BigDecimal getArrayFirstBigDecimal(int index,
BigDecimal defaultValue)
Description copied from interface: JsonArray
Gets the first element (as BigDecimal) of a JsonArray
element.
- Specified by:
getArrayFirstBigDecimal
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if the array or
the first element are not found.
-
getArrayFirstBytesFromBase64String
public byte[] getArrayFirstBytesFromBase64String(int index)
Description copied from interface: JsonArray
Gets the first element (as byte[]) of a JsonArray
element.
- Specified by:
getArrayFirstBytesFromBase64String
in interface JsonArray
- Returns:
- the element or
null
if the array or
the first element are not found.
-
getArrayFirstBytesFromBase64String
public byte[] getArrayFirstBytesFromBase64String(int index,
byte[] defaultValue)
Description copied from interface: JsonArray
Gets the first element (as byte[]) of a JsonArray
element.
- Specified by:
getArrayFirstBytesFromBase64String
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if the array or
the first element are not found.
-
getArrayFirstDate
public Date getArrayFirstDate(int index)
Description copied from interface: JsonArray
Gets the first element (as Date) of a JsonArray
element.
- Specified by:
getArrayFirstDate
in interface JsonArray
- Returns:
- the element or
null
if the array or
the first element are not found.
-
getArrayFirstDate
public Date getArrayFirstDate(int index,
Date defaultValue)
Description copied from interface: JsonArray
Gets the first element (as Date) of a JsonArray
element.
- Specified by:
getArrayFirstDate
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if the array or
the first element are not found.
-
getArrayFirstInstant
public Instant getArrayFirstInstant(int index)
Description copied from interface: JsonArray
Gets the first element (as Instant) of a JsonArray
element.
- Specified by:
getArrayFirstInstant
in interface JsonArray
- Returns:
- the element or
null
if the array or
the first element are not found.
-
getArrayFirstInstant
public Instant getArrayFirstInstant(int index,
Instant defaultValue)
Description copied from interface: JsonArray
Gets the first element (as Instant) of a JsonArray
element.
- Specified by:
getArrayFirstInstant
in interface JsonArray
- Returns:
- the element or the specified
defaultValue
if the array or
the first element are not found.
-
convertToPlainList
public List<Object> convertToPlainList()
Description copied from interface: JsonArray
Converts the JsonArray
to a plain List<Object>
.
All JsonObject
elements will be converted to
Maps and all JsonArray
elements will be converted to
Lists.
This list is always a new instance and is mutable.
- Specified by:
convertToPlainList
in interface JsonArray
-
isCanBeConvertedToString
public boolean isCanBeConvertedToString(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
, of type String
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToString
in interface JsonArray
-
isCanBeConvertedToInteger
public boolean isCanBeConvertedToInteger(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
, of type Integer
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToInteger
in interface JsonArray
-
isCanBeConvertedToLong
public boolean isCanBeConvertedToLong(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
, of type Long
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToLong
in interface JsonArray
-
isCanBeConvertedToFloat
public boolean isCanBeConvertedToFloat(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
, of type Float
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToFloat
in interface JsonArray
-
isCanBeConvertedToDouble
public boolean isCanBeConvertedToDouble(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
, of type Double
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToDouble
in interface JsonArray
-
isCanBeConvertedToBoolean
public boolean isCanBeConvertedToBoolean(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
, of type Boolean
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToBoolean
in interface JsonArray
-
isCanBeConvertedToBigDecimal
public boolean isCanBeConvertedToBigDecimal(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
, of type BigDecimal
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToBigDecimal
in interface JsonArray
-
isCanBeConvertedToByteArray
public boolean isCanBeConvertedToByteArray(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
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 JsonArray
-
isCanBeConvertedToDate
public boolean isCanBeConvertedToDate(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
, of type Date
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToDate
in interface JsonArray
-
isCanBeConvertedToJsonObject
public boolean isCanBeConvertedToJsonObject(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
, of type JsonObject
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToJsonObject
in interface JsonArray
-
isCanBeConvertedToJsonArray
public boolean isCanBeConvertedToJsonArray(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
, of type JsonArray
, or can be
converted and retrieved as one.
- Specified by:
isCanBeConvertedToJsonArray
in interface JsonArray
-
isOfTypeString
public boolean isOfTypeString(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
or of type String
, without requiring
any conversion.
- Specified by:
isOfTypeString
in interface JsonArray
-
isOfTypeInteger
public boolean isOfTypeInteger(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
or of type Integer
, without requiring
any conversion.
- Specified by:
isOfTypeInteger
in interface JsonArray
-
isOfTypeLong
public boolean isOfTypeLong(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
or of type Long
, without requiring
any conversion.
- Specified by:
isOfTypeLong
in interface JsonArray
-
isOfTypeFloat
public boolean isOfTypeFloat(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
or of type Float
, without requiring
any conversion.
- Specified by:
isOfTypeFloat
in interface JsonArray
-
isOfTypeDouble
public boolean isOfTypeDouble(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
or of type Double
, without requiring
any conversion.
- Specified by:
isOfTypeDouble
in interface JsonArray
-
isOfTypeBoolean
public boolean isOfTypeBoolean(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
or of type Boolean
, without requiring
any conversion.
- Specified by:
isOfTypeBoolean
in interface JsonArray
-
isOfTypeBigDecimal
public boolean isOfTypeBigDecimal(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
or of type BigDecimal
, without requiring
any conversion.
- Specified by:
isOfTypeBigDecimal
in interface JsonArray
-
isOfTypeByteArray
public boolean isOfTypeByteArray(int index,
boolean acceptBase64StringToo)
Description copied from interface: JsonArray
Validates that the element at the specified JsonPath
exists and
is currently null
or of type byte[]
, without requiring
any conversion.
- Specified by:
isOfTypeByteArray
in interface JsonArray
acceptBase64StringToo
- if true
, then a valid base 64 String
will also be accepted.
-
isOfTypeDate
public boolean isOfTypeDate(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
or of type Date
, without requiring
any conversion.
- Specified by:
isOfTypeDate
in interface JsonArray
-
isOfTypeJsonObject
public boolean isOfTypeJsonObject(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
or of type JsonObject
, without requiring
any conversion.
- Specified by:
isOfTypeJsonObject
in interface JsonArray
-
isOfTypeJsonArray
public boolean isOfTypeJsonArray(int index)
Description copied from interface: JsonArray
Validates that the element at the specified index
exists and
is currently null
or of type JsonArray
, without requiring
any conversion.
- Specified by:
isOfTypeJsonArray
in interface JsonArray
-
isNull
public boolean isNull(int index)
Description copied from interface: JsonArray
Validates that there is an element at the specified index
and
it is null
.
-
isEquivalentTo
public boolean isEquivalentTo(JsonArray other)
Description copied from interface: JsonArray
Compares the current JsonArray
to the specified one
and returns true
if they are equivalent. To be equivalent,
all their elements must be so too.
An element is equivalent to the other if they can be converted to the¸
same type, and then if they are equals.
For example, the String
"123" is equivalent to
new BigDecimal("123")
or to 123L
.
- Specified by:
isEquivalentTo
in interface JsonArray
-
clone
public JsonArray clone(boolean mutable)
Description copied from class: JsonObjectArrayBase
Clone the object.
- Specified by:
clone
in interface JsonArray
- Specified by:
clone
in interface JsonObjectOrArray
- Specified by:
clone
in class JsonObjectArrayBase
- Parameters:
mutable
- if true
the resulting
object and all its children will be mutable, otherwise
they will all be immutable.
-
transformAll
public 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
- Specified by:
transformAll
in class JsonObjectArrayBase
recursive
- if true
,
then all children elements will also be transformed,
recursively.
-
transform
public void transform(int index,
ElementTransformer transformer)
Description copied from interface: JsonArray
Transforms the element at the given index, using the
specified ElementTransformer
.
-
trim
public void trim(int index)
Description copied from interface: JsonArray
Trims the element, if it's of type String
.
-
putAsIs
protected JsonArray putAsIs(String key,
Object value)
- Specified by:
putAsIs
in class JsonObjectArrayBase
Copyright © 2019. All rights reserved.