Class JSONObjectImpl
- All Implemented Interfaces:
Iterable<JSONValue>, Formattable, JSONObject, JSONValue
The implementation for the interface
JSONObject.
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: JSONObjectImpl.java 1195 2026-04-15 21:33:40Z tquadrat $
- Since:
- 0.25.0
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.jsonbuilder.internal.JSONObjectImpl"
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final JSONBuilderImplThe reference to theJSONBuilderthat was used to create thisJSONObject, and that is used to create the members.private final SequencedMap<String, JSONValue> The members of thisJSONObject. -
Constructor Summary
ConstructorsConstructorDescriptionJSONObjectImpl(JSONBuilderImpl builder) Creates a new instance ofJSONObjectImpl.JSONObjectImpl(JSONObjectImpl other) {summary Creates a new instance ofJSONObjectImplfrom the given other object.} -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanChecks if a specified member is present as a child of this object.final booleanvoidReturns the value of the member with the specified name in this object.final inthashCode()final booleanisEmpty()Checks whether this object has members.iterator()merge(JSONObject object) Copies all members of the specified object into this object.final SequencedCollection<String> names()Returns the names of the members of this object in document order.final JSONObjectRemoves a member with the specified name from this object.final JSONObjectSets the value of the member with the specified name to the JSON representation of the specifieddoublevalue.final JSONObjectSets the value of the member with the specified name to the JSON representation of the specifiedfloatvalue.final JSONObjectSets the value of the member with the specified name to the JSON representation of the specifiedintvalue.final JSONObjectSets the value of the member with the specified name to the JSON representation of the specifiedlongvalue.final JSONObjectSets the value of the member with the specified name to the JSON representation of the specifiedDoublevalue.final JSONObjectSets the value of the member with the specified name to the JSON representation of the specifiedFloatvalue.final JSONObjectSets the value of the member with the specified name to the JSON representation of the specifiedIntegervalue.final JSONObjectSets the value of the member with the specified name to the JSON representation of the specifiedLongvalue.final JSONObjectSets the value of the member with the specified name to the JSON representation of the specifiedStringvalue.final JSONObjectset(String name, BigDecimal value) Sets the value of the member with the specified name to the JSON representation of the specifiedBigDecimalvalue.final JSONObjectset(String name, BigInteger value) Sets the value of the member with the specified name to the JSON representation of the specifiedBigIntegervalue.final JSONObjectSets the value of the member with the specified name to the specifiedJSONValuevalue.<T extends Dimension>
JSONObjectset(String name, DimensionedValue<T> value, T targetUnit) Sets the value of the member with the specified name to the JSON representation of the specifiedDimensionedValuevalue.final JSONArraySets a new empty instance ofJSONArrayto this object and returns that.final JSONObjectSets a new empty instance ofJSONObjectto this object and returns that.final intsize()Returns the number of members (name/value pairs) in this object.final StringtoString()Methods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface JSONObject
getArray, getBigDecimal, getBigInteger, getBoolean, getDouble, getFloat, getInt, getLong, getObject, getString, set
-
Field Details
-
m_Builder
The reference to theJSONBuilderthat was used to create thisJSONObject, and that is used to create the members. -
m_Members
The members of thisJSONObject.
-
-
Constructor Details
-
JSONObjectImpl
Creates a new instance ofJSONObjectImpl.- Parameters:
builder- The reference to theJSONBuilder.
-
JSONObjectImpl
{summary Creates a new instance of
JSONObjectImplfrom the given other object.}The new object is a deep copy of the given instance.
- Parameters:
other- The other JSON object.
-
-
Method Details
-
contains
Checks if a specified member is present as a child of this object. This will not test if that child is the JSON literal
null, This needs to be tested separately.- Specified by:
containsin interfaceJSONObject- Parameters:
name- The name of the member to check for.- Returns:
trueif there is a member with the given name,falseif not.
-
equals
-
formatTo
-
get
-
hashCode
-
isEmpty
Checks whether this object has members.- Specified by:
isEmptyin interfaceJSONObject- Returns:
trueif the object does not have any members,falseotherwise.
-
iterator
-
merge
Copies all members of the specified object into this object. When the specified object contains members with names that also exist in this object, the existing values in this object will be replaced by the corresponding values in the specified object.
- Specified by:
mergein interfaceJSONObject- Parameters:
object- The object to merge.- Returns:
- This object itself, to enable method chaining.
-
names
Returns the names of the members of this object in document order.
The return value is backed by this object and will reflect subsequent changes. It cannot be used to modify this object. Attempts to modify the returned data structure will result in an exception.
- Specified by:
namesin interfaceJSONObject- Returns:
- The names.
-
remove
Removes a member with the specified name from this object. If this object does not contain a member with the specified name, the object is not modified.
- Specified by:
removein interfaceJSONObject- Parameters:
name- The name of the member to remove.- Returns:
- This object itself, to enable method chaining.
-
set
Sets the value of the member with the specified name to the JSON representation of the specified
BigDecimalvalue.If this object does not contain a member with this name, a new member is added at the end of the object.
- Specified by:
setin interfaceJSONObject- Parameters:
name- The name of the member to replace or to add.value- The value to set to the member.- Returns:
- This object itself, to enable method chaining.
-
set
Sets the value of the member with the specified name to the JSON representation of the specified
BigIntegervalue.If this object does not contain a member with this name, a new member is added at the end of the object.
- Specified by:
setin interfaceJSONObject- Parameters:
name- The name of the member to replace or to add.value- The value to set to the member.- Returns:
- This object itself, to enable method chaining.
-
set
Sets the value of the member with the specified name to the JSON representation of the specified
DimensionedValuevalue.If this object does not contain a member with this name, a new member is added at the end of the object.
- Specified by:
setin interfaceJSONObject- Type Parameters:
T- The type of the dimension for the value.- Parameters:
name- The name of the member to replace or to add.value- The value.targetUnit- The dimension for the output.- Returns:
- This object itself, to enable method chaining.
- See Also:
-
set
Sets the value of the member with the specified name to the JSON representation of the specified
doublevalue.If this object does not contain a member with this name, a new member is added at the end of the object.
- Specified by:
setin interfaceJSONObject- Parameters:
name- The name of the member to replace or to add.value- The value to set to the member.- Returns:
- This object itself, to enable method chaining.
-
set
Sets the value of the member with the specified name to the JSON representation of the specified
Doublevalue.If this object does not contain a member with this name, a new member is added at the end of the object.
- Specified by:
setin interfaceJSONObject- Parameters:
name- The name of the member to replace or to add.value- The value to set to the member.- Returns:
- This object itself, to enable method chaining.
-
set
Sets the value of the member with the specified name to the JSON representation of the specified
floatvalue.If this object does not contain a member with this name, a new member is added at the end of the object.
- Specified by:
setin interfaceJSONObject- Parameters:
name- The name of the member to replace or to add.value- The value to set to the member.- Returns:
- This object itself, to enable method chaining.
-
set
Sets the value of the member with the specified name to the JSON representation of the specified
Floatvalue.If this object does not contain a member with this name, a new member is added at the end of the object.
- Specified by:
setin interfaceJSONObject- Parameters:
name- The name of the member to replace or to add.value- The value to set to the member.- Returns:
- This object itself, to enable method chaining.
-
set
Sets the value of the member with the specified name to the JSON representation of the specified
intvalue.If this object does not contain a member with this name, a new member is added at the end of the object.
- Specified by:
setin interfaceJSONObject- Parameters:
name- The name of the member to replace or to add.value- The value to set to the member.- Returns:
- This object itself, to enable method chaining.
-
set
Sets the value of the member with the specified name to the JSON representation of the specified
Integervalue.If this object does not contain a member with this name, a new member is added at the end of the object.
- Specified by:
setin interfaceJSONObject- Parameters:
name- The name of the member to replace or to add.value- The value to set to the member.- Returns:
- This object itself, to enable method chaining.
-
set
Sets the value of the member with the specified name to the specified
JSONValuevalue.If this object does not contain a member with this name, a new member is added at the end of the object.
- Specified by:
setin interfaceJSONObject- Parameters:
name- The name of the member to replace or to add.value- The value to set to the member.- Returns:
- This object itself, to enable method chaining.
-
set
Sets the value of the member with the specified name to the JSON representation of the specified
longvalue.If this object does not contain a member with this name, a new member is added at the end of the object.
- Specified by:
setin interfaceJSONObject- Parameters:
name- The name of the member to replace or to add.value- The value to set to the member.- Returns:
- This object itself, to enable method chaining.
-
set
Sets the value of the member with the specified name to the JSON representation of the specified
Longvalue.If this object does not contain a member with this name, a new member is added at the end of the object.
- Specified by:
setin interfaceJSONObject- Parameters:
name- The name of the member to replace or to add.value- The value to set to the member.- Returns:
- This object itself, to enable method chaining.
-
set
Sets the value of the member with the specified name to the JSON representation of the specified
Stringvalue.If this object does not contain a member with this name, a new member is added at the end of the object.
- Specified by:
setin interfaceJSONObject- Parameters:
name- The name of the member to replace or to add.value- The value to set to the member.- Returns:
- This object itself, to enable method chaining.
-
setArray
-
setObject
Sets a new empty instance of
JSONObjectto this object and returns that.- Specified by:
setObjectin interfaceJSONObject- Parameters:
name- The name of the member.- Returns:
- The freshly created
JSONObject.
-
size
Returns the number of members (name/value pairs) in this object.
- Specified by:
sizein interfaceJSONObject- Returns:
- The number of members in this object.
-
toString
-
