public class JsonObject extends JsonObjectArrayBase implements IJsonObject
IJsonObject implementation.| Modifier and Type | Class and Description |
|---|---|
protected static interface |
JsonObject.IFirstElementGetter<T> |
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
JsonObject(IJsonManager jsonManager,
ISpincastUtils spincastUtils) |
JsonObject(Map<String,?> initialMap,
IJsonManager jsonManager,
ISpincastUtils spincastUtils) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addInitialMap() |
IJsonObject |
clone()
Deep copy of the
IJsonObject, so any
modification to the original won't affect the
clone, and vice-versa. |
IJsonObject |
clone(boolean mutable)
Deep copy of the
IJsonObject, so any
modification to the original won't affect the
clone, and vice-versa. |
Map<String,Object> |
convertToPlainMap()
Converts the
IJsonObject to a plain Map. |
protected <T> T |
getArrayFirst(String key,
boolean hasDefaultValue,
T defaultValue,
JsonObject.IFirstElementGetter<T> firstElementGetter) |
BigDecimal |
getArrayFirstBigDecimal(String key)
Gets the first value (as BigDecimal) of a
IJsonArray property
of the object. |
BigDecimal |
getArrayFirstBigDecimal(String key,
BigDecimal defaultValue)
Gets the first value (as BigDecimal) of a
IJsonArray property
of the object. |
protected BigDecimal |
getArrayFirstBigDecimal(String key,
boolean hasDefaultValue,
BigDecimal defaultValue) |
Boolean |
getArrayFirstBoolean(String key)
Gets the first value (as Boolean) of a
IJsonArray property
of the object. |
Boolean |
getArrayFirstBoolean(String key,
Boolean defaultValue)
Gets the first value (as Boolean) of a
IJsonArray property
of the object. |
protected Boolean |
getArrayFirstBoolean(String key,
boolean hasDefaultValue,
Boolean defaultValue) |
byte[] |
getArrayFirstBytesFromBase64String(String key)
Gets the first value (as byte[]) of a
IJsonArray property
of the object. |
protected byte[] |
getArrayFirstBytesFromBase64String(String key,
boolean hasDefaultValue,
byte[] defaultValue) |
byte[] |
getArrayFirstBytesFromBase64String(String key,
byte[] defaultValue)
Gets the first value (as byte[]) of a
IJsonArray property
of the object. |
Date |
getArrayFirstDate(String key)
Gets the first value (as Date) of a
IJsonArray property
of the object. |
protected Date |
getArrayFirstDate(String key,
boolean hasDefaultValue,
Date defaultValue) |
Date |
getArrayFirstDate(String key,
Date defaultValue)
Gets the first value (as Date) of a
IJsonArray property
of the object. |
Double |
getArrayFirstDouble(String key)
Gets the first value (as Double) of a
IJsonArray property
of the object. |
protected Double |
getArrayFirstDouble(String key,
boolean hasDefaultValue,
Double defaultValue) |
Double |
getArrayFirstDouble(String key,
Double defaultValue)
Gets the first value (as Double) of a
IJsonArray property
of the object. |
Float |
getArrayFirstFloat(String key)
Gets the first value (as Float) of a
IJsonArray property
of the object. |
protected Float |
getArrayFirstFloat(String key,
boolean hasDefaultValue,
Float defaultValue) |
Float |
getArrayFirstFloat(String key,
Float defaultValue)
Gets the first value (as Float) of a
IJsonArray property
of the object. |
Integer |
getArrayFirstInteger(String key)
Gets the first value (as Integer) of a
IJsonArray property
of the object. |
protected Integer |
getArrayFirstInteger(String key,
boolean hasDefaultValue,
Integer defaultValue) |
Integer |
getArrayFirstInteger(String key,
Integer defaultValue)
Gets the first value (as Integer) of a
IJsonArray property
of the object. |
IJsonArray |
getArrayFirstJsonArray(String key)
Gets the first value (as IJsonArray) of a
IJsonArray property
of the object. |
protected IJsonArray |
getArrayFirstJsonArray(String key,
boolean hasDefaultValue,
IJsonArray defaultValue) |
IJsonArray |
getArrayFirstJsonArray(String key,
IJsonArray defaultValue)
Gets the first value (as IJsonArray) of a
IJsonArray property
of the object. |
IJsonObject |
getArrayFirstJsonObject(String key)
Gets the first value (as IJsonObject) of a
IJsonArray property
of the object. |
protected IJsonObject |
getArrayFirstJsonObject(String key,
boolean hasDefaultValue,
IJsonObject defaultValue) |
IJsonObject |
getArrayFirstJsonObject(String key,
IJsonObject defaultValue)
Gets the first value (as IJsonObject) of a
IJsonArray property
of the object. |
Long |
getArrayFirstLong(String key)
Gets the first value (as Long) of a
IJsonArray property
of the object. |
protected Long |
getArrayFirstLong(String key,
boolean hasDefaultValue,
Long defaultValue) |
Long |
getArrayFirstLong(String key,
Long defaultValue)
Gets the first value (as Long) of a
IJsonArray property
of the object. |
String |
getArrayFirstString(String key)
Gets the first value (as String) of a
IJsonArray property
of the object. |
protected String |
getArrayFirstString(String key,
boolean hasDefaultValue,
String defaultValue) |
String |
getArrayFirstString(String key,
String defaultValue)
Gets the first value (as String) of a
IJsonArray property
of the object. |
protected Object |
getElement(String keyPosition,
boolean hasDefaultValue,
Object defaultValue)
Gets the element at this key/position.
|
protected Map<String,Object> |
getMap() |
protected void |
init()
Init
|
boolean |
isKeyExists(String key)
Does the object contain the specified key?
|
Iterator<Map.Entry<String,Object>> |
iterator() |
IJsonObject |
merge(IJsonObject jsonObj)
Merges the specified
IJsonObject properties in the current
object. |
IJsonObject |
merge(IJsonObject jsonObj,
boolean clone)
Merges the specified
IJsonObject properties in the current
object. |
IJsonObject |
merge(Map<String,Object> map)
Merges all the Map's entries in the IJsonObject.
|
IJsonObject |
merge(Map<String,Object> map,
boolean clone)
Merges all the Map's entries in the IJsonObject.
|
IJsonObject |
put(String key,
BigDecimal value)
Adds a BigDecimal.
|
IJsonObject |
put(String key,
Boolean value)
Adds a Boolean.
|
IJsonObject |
put(String key,
byte[] value)
Adds a byte[].
|
IJsonObject |
put(String key,
Date value)
Adds a Date.
|
IJsonObject |
put(String key,
Double value)
Adds a Double.
|
IJsonObject |
put(String key,
Float value)
Adds a Float.
|
IJsonObject |
put(String key,
IJsonArray value)
Adds a IJsonArray.
|
IJsonObject |
put(String key,
IJsonArray value,
boolean clone)
Adds a IJsonArray.
|
IJsonObject |
put(String key,
IJsonObject value)
Adds a IJsonObject.
|
IJsonObject |
put(String key,
IJsonObject value,
boolean clone)
Adds a IJsonObject.
|
IJsonObject |
put(String key,
Integer value)
Adds a Integer.
|
IJsonObject |
put(String key,
Long value)
Adds a Long.
|
IJsonObject |
put(String key,
String value)
Adds a String.
|
protected IJsonObject |
putAsIs(String key,
Object value) |
IJsonObject |
putConvert(String key,
Object value)
If the object to add is not of a IJsonObject's native type,
the object is converted to a IJsonObject or a
IJsonArray before being added.
|
IJsonObject |
putConvert(String key,
Object value,
boolean clone)
If the object to add is not of a IJsonObject's native type,
the object is converted to a IJsonObject or a
IJsonArray before being added.
|
IJsonObject |
remove(String key)
Removes a property from the object.
|
IJsonObject |
removeAll()
Removes all properties from the object.
|
getBigDecimal, getBigDecimal, getBigDecimalValue, getBoolean, getBoolean, getBooleanValue, getBytesFromBase64String, getBytesFromBase64String, getBytesFromBase64StringValue, getDate, getDate, getDateValue, getDouble, getDouble, getDoubleValue, getFloat, getFloat, getFloatValue, getInteger, getInteger, getIntegerValue, getJsonArray, getJsonArray, getJsonArrayOrEmpty, getJsonArrayValue, getJsonManager, getJsonObject, getJsonObject, getJsonObjectOrEmpty, getJSONObjectValue, getLong, getLong, getLongValue, getSpincastUtils, getString, getString, getStringValue, parseDate, toJsonString, toJsonString, toStringequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetBigDecimal, getBigDecimal, getBoolean, getBoolean, getBytesFromBase64String, getBytesFromBase64String, getDate, getDate, getDouble, getDouble, getFloat, getFloat, getInteger, getInteger, getJsonArray, getJsonArray, getJsonArrayOrEmpty, getJsonObject, getJsonObject, getJsonObjectOrEmpty, getLong, getLong, getString, getString, toJsonString, toJsonStringforEach, spliteratorpublic JsonObject(IJsonManager jsonManager, ISpincastUtils spincastUtils)
public JsonObject(@Nullable Map<String,?> initialMap, IJsonManager jsonManager, ISpincastUtils spincastUtils)
@Inject protected void init()
protected void addInitialMap()
public IJsonObject put(String key, String value)
IJsonObjectput in interface IJsonObjectpublic IJsonObject put(String key, Integer value)
IJsonObjectput in interface IJsonObjectpublic IJsonObject put(String key, Long value)
IJsonObjectput in interface IJsonObjectpublic IJsonObject put(String key, Float value)
IJsonObjectput in interface IJsonObjectpublic IJsonObject put(String key, Double value)
IJsonObjectput in interface IJsonObjectpublic IJsonObject put(String key, Boolean value)
IJsonObjectput in interface IJsonObjectpublic IJsonObject put(String key, BigDecimal value)
IJsonObjectput in interface IJsonObjectpublic IJsonObject put(String key, byte[] value)
IJsonObjectput in interface IJsonObjectpublic IJsonObject put(String key, Date value)
IJsonObjectput in interface IJsonObjectpublic IJsonObject put(String key, IJsonObject value)
IJsonObjectIJsonObject
WILL affect the added element. There is an exception though :
if the IJsonObject to add is immutable
then it will always be cloned. Doing so, we can make sure a
IJsonObject is always
fully mutable or fully immutable.put in interface IJsonObjectpublic IJsonObject put(String key, IJsonObject value, boolean clone)
IJsonObjectput in interface IJsonObjectclone - if true, a clone of the original
IJsonObject will be made before being added.
If that case, any modification to the original IJsonObject
won't affect the added element, and vice-versa.
If the IJsonObject
to add is immutable then it will always be cloned.
Doing so, we can make sure a IJsonObject is always
fully mutable or fully immutable.public IJsonObject put(String key, IJsonArray value)
IJsonObjectIJsonArray
WILL affect the added element, and vice-versa.
There is an exception though :
if the IJsonArray to add is immutable
then it will always be cloned. Doing so, we can make sure a
IJsonObject is always
fully mutable or fully immutable.put in interface IJsonObjectpublic IJsonObject put(String key, IJsonArray value, boolean clone)
IJsonObjectput in interface IJsonObjectclone - if true, a clone of the original
IJsonArray will be made before being added.
If that case, any modification to the original IJsonArray
won't affect the added element, and vice-versa.
If the IJsonArray
to add is immutable then it will always be cloned.
Doing so, we can make sure a IJsonObject is always
fully mutable or fully immutable.protected IJsonObject putAsIs(String key, Object value)
public IJsonObject putConvert(String key, Object value)
IJsonObject
If the element to add is a IJsonObject or
a IJsonArray and is immutable then
it will be cloned.
Doing so, we can make sure a IJsonObject is always
fully mutable or fully immutable.
Those are the types of object that will be converted to a IJsonArray instead of a IJsonObject :
putConvert in interface IJsonObjectpublic IJsonObject putConvert(String key, Object value, boolean clone)
IJsonObjectThose are the types of object that will be converted to a IJsonArray instead of a IJsonObject :
putConvert in interface IJsonObjectclone - if true, and the element to add is a
IJsonObject or IJsonArray, 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
IJsonObject is always
fully mutable or fully immutable.public IJsonObject merge(Map<String,Object> map)
IJsonObject
Note that the IJsonObject and IJsonArray 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
IJsonObject is always
fully mutable or fully immutable.
Any none primitive (or BigDecimal) object will
be converted to a IJsonObject or a
IJsonArray.
Those are the types of object that will be converted to a
IJsonArray instead of a IJsonObject
merge in interface IJsonObjectpublic IJsonObject merge(Map<String,Object> map, boolean clone)
IJsonObject
Any none primitive (or BigDecimal) object will
be converted to a IJsonObject or a
IJsonArray.
Those are the types of object that will be converted to a
IJsonArray instead of a IJsonObject :
merge in interface IJsonObjectclone - if true, a clone of any
IJsonObject or IJsonArray 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 a
IJsonObject is always
fully mutable or fully immutable.public IJsonObject merge(IJsonObject jsonObj)
IJsonObjectIJsonObject properties in the current
object. Overwrites entries of the same keys.
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
IJsonObject is always
fully mutable or fully immutable.
merge in interface IJsonObjectpublic IJsonObject merge(IJsonObject jsonObj, boolean clone)
IJsonObjectIJsonObject properties in the current
object. Overwrites entries of the same keys.merge in interface IJsonObjectclone - if true, a clone of the original
IJsonObject 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 a
IJsonObject is always
fully mutable or fully immutable.public IJsonObject remove(String key)
IJsonObjectremove in interface IJsonObjectpublic IJsonObject removeAll()
IJsonObjectremoveAll in interface IJsonObjectpublic boolean isKeyExists(String key)
IJsonObjectisKeyExists in interface IJsonObjectprotected <T> T getArrayFirst(String key, boolean hasDefaultValue, T defaultValue, JsonObject.IFirstElementGetter<T> firstElementGetter)
public IJsonObject getArrayFirstJsonObject(String key)
IJsonObjectIJsonArray property
of the object.getArrayFirstJsonObject in interface IJsonObjectnull if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.public IJsonObject getArrayFirstJsonObject(String key, IJsonObject defaultValue)
IJsonObjectIJsonArray property
of the object.getArrayFirstJsonObject in interface IJsonObjectdefaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.protected IJsonObject getArrayFirstJsonObject(String key, boolean hasDefaultValue, IJsonObject defaultValue)
public IJsonArray getArrayFirstJsonArray(String key)
IJsonObjectIJsonArray property
of the object.getArrayFirstJsonArray in interface IJsonObjectnull if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.public IJsonArray getArrayFirstJsonArray(String key, IJsonArray defaultValue)
IJsonObjectIJsonArray property
of the object.getArrayFirstJsonArray in interface IJsonObjectdefaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.protected IJsonArray getArrayFirstJsonArray(String key, boolean hasDefaultValue, IJsonArray defaultValue)
public String getArrayFirstString(String key)
IJsonObjectIJsonArray property
of the object.getArrayFirstString in interface IJsonObjectnull if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.public String getArrayFirstString(String key, String defaultValue)
IJsonObjectIJsonArray property
of the object.getArrayFirstString in interface IJsonObjectdefaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.protected String getArrayFirstString(String key, boolean hasDefaultValue, String defaultValue)
public Integer getArrayFirstInteger(String key)
IJsonObjectIJsonArray property
of the object.getArrayFirstInteger in interface IJsonObjectnull if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.public Integer getArrayFirstInteger(String key, Integer defaultValue)
IJsonObjectIJsonArray property
of the object.getArrayFirstInteger in interface IJsonObjectdefaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.protected Integer getArrayFirstInteger(String key, boolean hasDefaultValue, Integer defaultValue)
public Long getArrayFirstLong(String key)
IJsonObjectIJsonArray property
of the object.getArrayFirstLong in interface IJsonObjectnull if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.public Long getArrayFirstLong(String key, Long defaultValue)
IJsonObjectIJsonArray property
of the object.getArrayFirstLong in interface IJsonObjectdefaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.protected Long getArrayFirstLong(String key, boolean hasDefaultValue, Long defaultValue)
public Double getArrayFirstDouble(String key)
IJsonObjectIJsonArray property
of the object.getArrayFirstDouble in interface IJsonObjectnull if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.public Double getArrayFirstDouble(String key, Double defaultValue)
IJsonObjectIJsonArray property
of the object.getArrayFirstDouble in interface IJsonObjectdefaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.protected Double getArrayFirstDouble(String key, boolean hasDefaultValue, Double defaultValue)
public Float getArrayFirstFloat(String key)
IJsonObjectIJsonArray property
of the object.getArrayFirstFloat in interface IJsonObjectnull if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.public Float getArrayFirstFloat(String key, Float defaultValue)
IJsonObjectIJsonArray property
of the object.getArrayFirstFloat in interface IJsonObjectdefaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.protected Float getArrayFirstFloat(String key, boolean hasDefaultValue, Float defaultValue)
public Boolean getArrayFirstBoolean(String key)
IJsonObjectIJsonArray property
of the object.getArrayFirstBoolean in interface IJsonObjectnull if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.public Boolean getArrayFirstBoolean(String key, Boolean defaultValue)
IJsonObjectIJsonArray property
of the object.getArrayFirstBoolean in interface IJsonObjectdefaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.protected Boolean getArrayFirstBoolean(String key, boolean hasDefaultValue, Boolean defaultValue)
public BigDecimal getArrayFirstBigDecimal(String key)
IJsonObjectIJsonArray property
of the object.getArrayFirstBigDecimal in interface IJsonObjectnull if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.public BigDecimal getArrayFirstBigDecimal(String key, BigDecimal defaultValue)
IJsonObjectIJsonArray property
of the object.getArrayFirstBigDecimal in interface IJsonObjectdefaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.protected BigDecimal getArrayFirstBigDecimal(String key, boolean hasDefaultValue, BigDecimal defaultValue)
public byte[] getArrayFirstBytesFromBase64String(String key)
IJsonObjectIJsonArray property
of the object.getArrayFirstBytesFromBase64String in interface IJsonObjectnull if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.public byte[] getArrayFirstBytesFromBase64String(String key, byte[] defaultValue)
IJsonObjectIJsonArray property
of the object.getArrayFirstBytesFromBase64String in interface IJsonObjectdefaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.protected byte[] getArrayFirstBytesFromBase64String(String key, boolean hasDefaultValue, byte[] defaultValue)
public Date getArrayFirstDate(String key)
IJsonObjectIJsonArray property
of the object.getArrayFirstDate in interface IJsonObjectnull if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.public Date getArrayFirstDate(String key, Date defaultValue)
IJsonObjectIJsonArray property
of the object.getArrayFirstDate in interface IJsonObjectdefaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.protected Date getArrayFirstDate(String key, boolean hasDefaultValue, Date defaultValue)
public IJsonObject clone()
IJsonObjectIJsonObject, so any
modification to the original won't affect the
clone, and vice-versa.
The resulting IJsonObject is mutable.
clone in interface IJsonObjectclone in class Objectpublic IJsonObject clone(boolean mutable)
IJsonObjectIJsonObject, so any
modification to the original won't affect the
clone, and vice-versa.clone in interface IJsonObjectmutable - if false, the resulting
IJsonObject and all its children
will be immutable.protected Object getElement(String keyPosition, boolean hasDefaultValue, Object defaultValue)
JsonObjectArrayBasegetElement in class JsonObjectArrayBasepublic Map<String,Object> convertToPlainMap()
IJsonObjectIJsonObject to a plain Map.
All IJsonObject children will be converted to
Maps and all IJsonArray children will be converted to
Lists.convertToPlainMap in interface IJsonObjectCopyright © 2016. All rights reserved.