Package com.github.tnakamot.json.value
Class JSONValueObject
- java.lang.Object
-
- com.github.tnakamot.json.value.JSONValue
-
- com.github.tnakamot.json.value.JSONValueStructured
-
- com.github.tnakamot.json.value.JSONValueObject
-
- All Implemented Interfaces:
Map<JSONValueString,JSONValue>
- Direct Known Subclasses:
JSONValueObjectImmutable
,JSONValueObjectMutable
public abstract class JSONValueObject extends JSONValueStructured implements Map<JSONValueString,JSONValue>
Represents one JSON 'object' value.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
clear()
abstract boolean
containsKey(Object o)
abstract boolean
containsKey(String name)
Check if this JSON object has a value which has the given name.abstract boolean
containsValue(Object o)
abstract @NotNull Set<Map.Entry<JSONValueString,JSONValue>>
entrySet()
boolean
equals(Object o)
abstract JSONValue
get(JSONValueString name)
Returns the JSON value of the given name.abstract JSONValue
get(Object o)
abstract JSONValue
get(String name)
Returns the JSON value which has the given name.JSONValueArray
getArray(String key)
Returns the array value to which the specified key is mapped, or null if this map contains no mapping for the key.boolean
getBoolean(String key)
Returns the boolean value to which the specified key is mapped, or null if this map contains no mapping for the key.double
getDouble(String key)
Returns the double value to which the specified key is mapped, or null if this map contains no mapping for the key.long
getLong(String key)
Returns the long value to which the specified key is mapped, or null if this map contains no mapping for the key.JSONValueObject
getObject(String key)
Returns the object value to which the specified key is mapped, or null if this map contains no mapping for the key.String
getString(String key)
Returns the string value to which the specified key is mapped, or null if this map contains no mapping for the key.int
hashCode()
abstract boolean
isEmpty()
abstract @NotNull Set<JSONValueString>
keySet()
abstract JSONValue
put(JSONValueString jsonValueString, JSONValue jsonValue)
JSONValue
put(String key, boolean value)
Associates the specified boolean value with the specified key in this JSON object.JSONValue
put(String key, double value)
Associates the specified number value with the specified key in this JSON object.JSONValue
put(String key, long value)
Associates the specified number value with the specified key in this JSON object.JSONValue
put(String key, JSONValue value)
Associates the specified value with the specified key in this JSON object.JSONValue
put(String key, String value)
Associates the specified string value with the specified key in this JSON object.abstract void
putAll(@NotNull Map<? extends JSONValueString,? extends JSONValue> map)
abstract JSONValue
remove(Object o)
JSONValue
remove(String key)
abstract int
size()
abstract @NotNull Collection<JSONValue>
values()
-
Methods inherited from class com.github.tnakamot.json.value.JSONValueStructured
begin, end
-
Methods inherited from class com.github.tnakamot.json.value.JSONValue
toTokenBytes, toTokenBytes, toTokenString, toTokenString, type
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
get
public abstract JSONValue get(JSONValueString name)
Returns the JSON value of the given name.If a value of the given name does not exist, this method returns null. Do not confuse it with a JSON 'null' value. If there is a JSON 'null' value of the given name, this method returns an instance of
JSONValueNull
instead.- Parameters:
name
- a JSON string value which represents a name- Returns:
- a JSON value of the given name
-
get
public abstract JSONValue get(String name)
Returns the JSON value which has the given name.- Parameters:
name
- name- Returns:
- a JSON value of the given name
- See Also:
get(JSONValueString)
-
size
public abstract int size()
- Specified by:
size
in interfaceMap<JSONValueString,JSONValue>
-
isEmpty
public abstract boolean isEmpty()
- Specified by:
isEmpty
in interfaceMap<JSONValueString,JSONValue>
-
containsKey
public abstract boolean containsKey(Object o)
- Specified by:
containsKey
in interfaceMap<JSONValueString,JSONValue>
-
containsKey
public abstract boolean containsKey(String name)
Check if this JSON object has a value which has the given name.- Parameters:
name
- name- Returns:
- true if a value with the given name exists
- See Also:
containsKey(Object)
-
containsValue
public abstract boolean containsValue(Object o)
- Specified by:
containsValue
in interfaceMap<JSONValueString,JSONValue>
-
get
public abstract JSONValue get(Object o)
- Specified by:
get
in interfaceMap<JSONValueString,JSONValue>
-
put
public abstract JSONValue put(JSONValueString jsonValueString, JSONValue jsonValue)
- Specified by:
put
in interfaceMap<JSONValueString,JSONValue>
-
remove
public abstract JSONValue remove(Object o)
- Specified by:
remove
in interfaceMap<JSONValueString,JSONValue>
-
putAll
public abstract void putAll(@NotNull @NotNull Map<? extends JSONValueString,? extends JSONValue> map)
- Specified by:
putAll
in interfaceMap<JSONValueString,JSONValue>
-
clear
public abstract void clear()
- Specified by:
clear
in interfaceMap<JSONValueString,JSONValue>
-
keySet
@NotNull public abstract @NotNull Set<JSONValueString> keySet()
- Specified by:
keySet
in interfaceMap<JSONValueString,JSONValue>
-
values
@NotNull public abstract @NotNull Collection<JSONValue> values()
- Specified by:
values
in interfaceMap<JSONValueString,JSONValue>
-
entrySet
@NotNull public abstract @NotNull Set<Map.Entry<JSONValueString,JSONValue>> entrySet()
- Specified by:
entrySet
in interfaceMap<JSONValueString,JSONValue>
-
put
public JSONValue put(String key, JSONValue value)
Associates the specified value with the specified key in this JSON object.- Parameters:
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified key- Returns:
- the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)
-
put
public JSONValue put(String key, boolean value)
Associates the specified boolean value with the specified key in this JSON object.- Parameters:
key
- key with which the specified value is to be associatedvalue
- booolean value to be associated with the specified key- Returns:
- the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)
-
put
public JSONValue put(String key, long value)
Associates the specified number value with the specified key in this JSON object.- Parameters:
key
- key with which the specified value is to be associatedvalue
- number value to be associated with the specified key- Returns:
- the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)
-
put
public JSONValue put(String key, double value)
Associates the specified number value with the specified key in this JSON object.- Parameters:
key
- key with which the specified value is to be associatedvalue
- number value to be associated with the specified key- Returns:
- the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)
-
put
public JSONValue put(String key, String value)
Associates the specified string value with the specified key in this JSON object.- Parameters:
key
- key with which the specified value is to be associatedvalue
- string alue to be associated with the specified key. Null is considered as an empty string.- Returns:
- the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)
-
getBoolean
public boolean getBoolean(String key)
Returns the boolean value to which the specified key is mapped, or null if this map contains no mapping for the key.- Parameters:
key
- the key whose associated value is to be returned- Returns:
- the value to which the specified key is mapped
- Throws:
WrongValueTypeException
- if the value type is not booleanIllegalArgumentException
- if this object contains no mapping for the key
-
getLong
public long getLong(String key)
Returns the long value to which the specified key is mapped, or null if this map contains no mapping for the key.- Parameters:
key
- the key whose associated value is to be returned- Returns:
- the value to which the specified key is mapped
- Throws:
WrongValueTypeException
- if the value type is not numberNumberFormatException
- if the value cannot be converted to a Java long valueIllegalArgumentException
- if this object contains no mapping for the key
-
getDouble
public double getDouble(String key)
Returns the double value to which the specified key is mapped, or null if this map contains no mapping for the key.- Parameters:
key
- the key whose associated value is to be returned- Returns:
- the value to which the specified key is mapped
- Throws:
WrongValueTypeException
- if the value type is not numberIllegalArgumentException
- if this object contains no mapping for the key
-
getString
public String getString(String key)
Returns the string value to which the specified key is mapped, or null if this map contains no mapping for the key.- Parameters:
key
- the key whose associated value is to be returned- Returns:
- the value to which the specified key is mapped
- Throws:
WrongValueTypeException
- if the value type is not stringIllegalArgumentException
- if this object contains no mapping for the key
-
getArray
public JSONValueArray getArray(String key)
Returns the array value to which the specified key is mapped, or null if this map contains no mapping for the key.- Parameters:
key
- the key whose associated value is to be returned- Returns:
- the value to which the specified key is mapped
- Throws:
WrongValueTypeException
- if the value type is not arrayIllegalArgumentException
- if this object contains no mapping for the key
-
getObject
public JSONValueObject getObject(String key)
Returns the object value to which the specified key is mapped, or null if this map contains no mapping for the key.- Parameters:
key
- the key whose associated value is to be returned- Returns:
- the value to which the specified key is mapped
- Throws:
WrongValueTypeException
- if the value type is not objectIllegalArgumentException
- if this object contains no mapping for the key
-
hashCode
public int hashCode()
-
-