Class JsonObjectDefault
- All Implemented Interfaces:
Iterable<Map.Entry<String,
,Object>> JsonObject
,JsonObjectOrArray
- Direct Known Subclasses:
FormDefault
JsonObject
implementation.-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static interface
Nested classes/interfaces inherited from class org.spincast.core.json.JsonObjectArrayBase
JsonObjectArrayBase.JsonPathCachingItem
-
Field Summary
Fields inherited from class org.spincast.core.json.JsonObjectArrayBase
defaultElementValidator
-
Constructor Summary
ConstructorDescriptionJsonObjectDefault
(Map<String, Object> initialMap, boolean mutable, JsonManager jsonManager, SpincastUtils spincastUtils, ObjectConverter objectConverter) ConstructorJsonObjectDefault
(Map<String, Object> initialMap, JsonManager jsonManager, SpincastUtils spincastUtils, ObjectConverter objectConverter) ConstructorJsonObjectDefault
(JsonManager jsonManager, SpincastUtils spincastUtils, ObjectConverter objectConverter) ConstructorJsonObjectDefault
(JsonObject configToMerge, boolean mutable, JsonManager jsonManager, SpincastUtils spincastUtils, ObjectConverter objectConverter) Constructor -
Method Summary
Modifier and TypeMethodDescriptionclear()
Clears all elements.clone
(boolean mutable) Clone the object.<T> T
Converts theJsonObject
to an instance of the specifiedT
type.Converts theJsonObject
to a plain Map.protected Object
getElementNoKeyParsing
(String jsonPath, boolean hasDefaultValue, Object defaultValue) Gets the element at this key/index, without key parsing.getMap()
boolean
Does the JsonObject contain an element at the specified key? The key is considered as is, without being parsed as aJsonPath
.boolean
isEquivalentTo
(JsonObject other) Compares the currentJsonObject
to the specified one and returnstrue
if they are equivalent.iterator()
Merges all the specified Map elements in the JsonObject.Merges all the specified Map elements in the JsonObject.merge
(JsonObject jsonObj) Merges the specifiedJsonObject
properties in the current object.merge
(JsonObject jsonObj, boolean clone) Merges the specifiedJsonObject
properties in the current object.Transforms the specifie3d object toJsonObject
and merges its properties in the current object.protected JsonObject
Removes a property atJsonPath
from the object.removeNoKeyParsing
(String key) Removes a element from the object.setNoKeyParsing
(String jsonPath, Object value) Sets an element at the specified key, without parsing this key as aJsonPath
.setNoKeyParsing
(String jsonPath, Object value, boolean clone) Sets an element at the specified key, without parsing this key as aJsonPath
.int
size()
The size of the object.void
transformAll
(ElementTransformer transformer, boolean recursive) Transforms all the elements of the object, using the specified transformer.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, isPresent, put, set, set, setIfAbsent, setIfAbsent, 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 java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.spincast.core.json.JsonObject
getArrayFirstBigDecimalNoKeyParsing, getArrayFirstBigDecimalNoKeyParsing, getArrayFirstBooleanNoKeyParsing, getArrayFirstBooleanNoKeyParsing, getArrayFirstBytesFromBase64StringNoKeyParsing, getArrayFirstBytesFromBase64StringNoKeyParsing, getArrayFirstDateNoKeyParsing, getArrayFirstDateNoKeyParsing, getArrayFirstDoubleNoKeyParsing, getArrayFirstDoubleNoKeyParsing, getArrayFirstFloatNoKeyParsing, getArrayFirstFloatNoKeyParsing, getArrayFirstIntegerNoKeyParsing, getArrayFirstIntegerNoKeyParsing, getArrayFirstJsonArrayNoKeyParsing, getArrayFirstJsonArrayNoKeyParsing, getArrayFirstJsonObjectNoKeyParsing, getArrayFirstJsonObjectNoKeyParsing, getArrayFirstLongNoKeyParsing, getArrayFirstLongNoKeyParsing, getArrayFirstStringNoKeyParsing, getArrayFirstStringNoKeyParsing, getBigDecimalNoKeyParsing, getBigDecimalNoKeyParsing, getBooleanNoKeyParsing, getBooleanNoKeyParsing, getBytesFromBase64StringNoKeyParsing, getBytesFromBase64StringNoKeyParsing, getDateNoKeyParsing, getDateNoKeyParsing, getDoubleNoKeyParsing, getDoubleNoKeyParsing, getFloatNoKeyParsing, getFloatNoKeyParsing, getInstantNoKeyParsing, getInstantNoKeyParsing, getIntegerNoKeyParsing, getIntegerNoKeyParsing, getJsonArrayNoKeyParsing, getJsonArrayNoKeyParsing, getJsonArrayOrEmptyNoKeyParsing, getJsonObjectNoKeyParsing, getJsonObjectNoKeyParsing, getJsonObjectOrEmptyNoKeyParsing, getLongNoKeyParsing, getLongNoKeyParsing, getObjectNoKeyParsing, getObjectNoKeyParsing, getStringNoKeyParsing, getStringNoKeyParsing, isCanBeConvertedToBigDecimalNoKeyParsing, isCanBeConvertedToBooleanNoKeyParsing, isCanBeConvertedToByteArrayNoKeyParsing, isCanBeConvertedToDateNoKeyParsing, isCanBeConvertedToDoubleNoKeyParsing, isCanBeConvertedToFloatNoKeyParsing, isCanBeConvertedToIntegerNoKeyParsing, isCanBeConvertedToJsonArrayNoKeyParsing, isCanBeConvertedToJsonObjectNoKeyParsing, isCanBeConvertedToLongNoKeyParsing, isCanBeConvertedToStringNoKeyParsing, isNullNoKeyParsing, isOfTypeBigDecimalNoKeyParsing, isOfTypeBooleanNoKeyParsing, isOfTypeByteArrayNoKeyParsing, isOfTypeDateNoKeyParsing, isOfTypeDoubleNoKeyParsing, isOfTypeFloatNoKeyParsing, isOfTypeIntegerNoKeyParsing, isOfTypeJsonArrayNoKeyParsing, isOfTypeJsonObjectNoKeyParsing, isOfTypeLongNoKeyParsing, isOfTypeStringNoKeyParsing
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, isPresent, set, set, setIfAbsent, setIfAbsent, toJsonString, toJsonString, transform, transformAll, trim, trimAll, trimAll
-
Field Details
-
logger
protected static final org.slf4j.Logger logger
-
-
Constructor Details
-
JsonObjectDefault
public JsonObjectDefault(JsonManager jsonManager, SpincastUtils spincastUtils, ObjectConverter objectConverter) Constructor -
JsonObjectDefault
public JsonObjectDefault(@Nullable Map<String, Object> initialMap, JsonManager jsonManager, SpincastUtils spincastUtils, ObjectConverter objectConverter) Constructor -
JsonObjectDefault
public JsonObjectDefault(@Nullable Map<String, Object> initialMap, boolean mutable, JsonManager jsonManager, SpincastUtils spincastUtils, ObjectConverter objectConverter) Constructor -
JsonObjectDefault
public JsonObjectDefault(@Nullable JsonObject configToMerge, boolean mutable, JsonManager jsonManager, SpincastUtils spincastUtils, ObjectConverter objectConverter) Constructor
-
-
Method Details
-
getMap
-
putAsIs
- Specified by:
putAsIs
in classJsonObjectArrayBase
-
setNoKeyParsing
Description copied from interface:JsonObject
Sets an element at the specified key, without parsing this key as aJsonPath
.If the 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 the element to add is a
JsonObject
or aJsonArray
and is immutable, it will be cloned. Doing so, we can make sure theJsonArray
is always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible
, it will be converted to aJsonObject
using the associated conversion method. If it implementsToJsonArrayConvertible
, it will be converted to anJsonArray
using the associated conversion method.Those are the types of objects that will be converted to a
JsonArray
instead of aJsonObject
, if no conversion interface is implemented :- A Collection
- An array
- Specified by:
setNoKeyParsing
in interfaceJsonObject
-
setNoKeyParsing
Description copied from interface:JsonObject
Sets an element at the specified key, without parsing this key as aJsonPath
.If the 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 the element to add is a
JsonObject
or aJsonArray
and is immutable, it will be cloned. Doing so, we can make sure theJsonArray
is always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible
, it will be converted to aJsonObject
using the associated conversion method. If it implementsToJsonArrayConvertible
, it will be converted to anJsonArray
using the associated conversion method.Those are the types of objects that will be converted to a
JsonArray
instead of aJsonObject
, if no conversion interface is implemented :- A Collection
- An array
- Specified by:
setNoKeyParsing
in interfaceJsonObject
clone
- iftrue
, and the element to add is aJsonObject
orJsonArray
, 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 aJsonObject
is always fully mutable or fully immutable.
-
merge
Description copied from interface:JsonObject
Merges all the specified Map elements in the JsonObject. The keys are parsed asJsonPaths
. Overwrites existing elements at the specified JsonPaths.Note that the JsonObject and JsonArray objects from the source will be added as is, so any modification to them WILL affect the added elements, and vise-versa. There is an exception though : if the element to add is immutable then it will always be cloned. Doing so, we can make sure a
JsonObject
is always fully mutable or fully immutable.If an element to 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 is a
JsonObject
or aJsonArray
and is immutable, it will be cloned. Doing so, we can make sure theJsonArray
is always fully mutable or fully immutable.If an element implements
ToJsonObjectConvertible
, it will be converted to aJsonObject
using the associated conversion method. If it implementsToJsonArrayConvertible
, it will be converted to anJsonArray
using the associated conversion method.Those are the types of objects that will be converted to a
JsonArray
instead of aJsonObject
, if no conversion interface is implemented :- A Collection
- An array
- Specified by:
merge
in interfaceJsonObject
-
merge
Description copied from interface:JsonObject
Merges all the specified Map elements in the JsonObject. The keys are parsed asJsonPaths
. Overwrites existing elements at the specified JsonPaths.If an element to 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 is a
JsonObject
or aJsonArray
and is immutable, it will be cloned. Doing so, we can make sure theJsonArray
is always fully mutable or fully immutable.If an element implements
ToJsonObjectConvertible
, it will be converted to aJsonObject
using the associated conversion method. If it implementsToJsonArrayConvertible
, it will be converted to anJsonArray
using the associated conversion method.Those are the types of objects that will be converted to a
JsonArray
instead of aJsonObject
, if no conversion interface is implemented :- A Collection
- An array
- Specified by:
merge
in interfaceJsonObject
clone
- iftrue
, a clone of anyJsonObject
orJsonArray
will be made before being added. If that case, any modification to the original elements won't affect the added elements, and vice-versa. If the element is immutable then it will always be cloned. Doing so, we can make sure aJsonObject
is always fully mutable or fully immutable.
-
merge
Description copied from interface:JsonObject
Merges the specifiedJsonObject
properties in the current object. Overwrites elements of the same JsonPaths.Note that the elements from the source are added as is, so any modification to them WILL affect the added element, and vise-versa. There is an exception though : if an element to add is immutable then it will always be cloned. Doing so, we can make sure a
JsonObject
is always fully mutable or fully immutable.- Specified by:
merge
in interfaceJsonObject
-
merge
Description copied from interface:JsonObject
Transforms the specifie3d object toJsonObject
and merges its properties in the current object. Overwrites elements of the same JsonPaths.- Specified by:
merge
in interfaceJsonObject
-
merge
Description copied from interface:JsonObject
Merges the specifiedJsonObject
properties in the current object. Overwrites elements of the same JsonPaths.- Specified by:
merge
in interfaceJsonObject
clone
- iftrue
, a clone of the originalJsonObject
will be made before being added. If that case, any modification to the original object won't affect the added element, and vice-versa. If an element is immutable then it will always be cloned. Doing so, we can make sure aJsonObject
is always fully mutable or fully immutable.
-
remove
Removes a property atJsonPath
from the object.- Specified by:
remove
in interfaceJsonObjectOrArray
- Returns:
- the current object (fluent style).
-
removeNoKeyParsing
Description copied from interface:JsonObject
Removes a element from the object. The key is used as is, without being parsed as aJsonPath
.- Specified by:
removeNoKeyParsing
in interfaceJsonObject
-
clear
Description copied from interface:JsonObjectOrArray
Clears all elements.- Specified by:
clear
in interfaceJsonObjectOrArray
-
isElementExistsNoKeyParsing
Description copied from interface:JsonObject
Does the JsonObject contain an element at the specified key? The key is considered as is, without being parsed as aJsonPath
.- Specified by:
isElementExistsNoKeyParsing
in interfaceJsonObject
-
iterator
-
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 classJsonObjectArrayBase
-
convertToPlainMap
Description copied from interface:JsonObject
Converts theJsonObject
to a plain Map. AllJsonObject
children will be converted to Maps and allJsonArray
children will be converted to Lists.- Specified by:
convertToPlainMap
in interfaceJsonObject
-
convert
Description copied from interface:JsonObject
Converts theJsonObject
to an instance of the specifiedT
type.This uses
JsonManager#fromJsonString
and may throw an exception if it is unable to do the conversion.- Specified by:
convert
in interfaceJsonObject
-
size
public int size()Description copied from interface:JsonObjectOrArray
The size of the object.- Specified by:
size
in interfaceJsonObjectOrArray
-
isEquivalentTo
Description copied from interface:JsonObject
Compares the currentJsonObject
to the specified one and returnstrue
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 tonew BigDecimal("123")
or to123L
.- Specified by:
isEquivalentTo
in interfaceJsonObject
-
clone
Description copied from class:JsonObjectArrayBase
Clone the object.- Specified by:
clone
in interfaceJsonObject
- Specified by:
clone
in interfaceJsonObjectOrArray
- Specified by:
clone
in classJsonObjectArrayBase
- Parameters:
mutable
- iftrue
the resulting object and all its children will be mutable, otherwise they will all be immutable.
-
transformAll
Description copied from interface:JsonObjectOrArray
Transforms all the elements of the object, using the specified transformer.- Specified by:
transformAll
in interfaceJsonObjectOrArray
- Specified by:
transformAll
in classJsonObjectArrayBase
recursive
- iftrue
, then all children elements will also be transformed, recursively.
-