- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<JsonValue>
-
- jakarta.json.EmptyArray
-
- All Implemented Interfaces:
JsonArray,JsonStructure,JsonValue,java.io.Serializable,java.lang.Iterable<JsonValue>,java.util.Collection<JsonValue>,java.util.List<JsonValue>,java.util.RandomAccess
final class EmptyArray extends java.util.AbstractList<JsonValue> implements JsonArray, java.io.Serializable, java.util.RandomAccess
Private implementation of immutableJsonArray.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jakarta.json.JsonValue
JsonValue.ValueType
-
-
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUIDfor serialization-
Fields inherited from interface jakarta.json.JsonValue
EMPTY_JSON_ARRAY, EMPTY_JSON_OBJECT, FALSE, NULL, TRUE
-
-
Constructor Summary
Constructors Constructor Description EmptyArray()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonValueget(int index)booleangetBoolean(int index)Returns the boolean value at the specified position.booleangetBoolean(int index, boolean defaultValue)Returns the boolean value at the specified position.intgetInt(int index)A convenience method forgetJsonNumber(index).intValue().intgetInt(int index, int defaultValue)Returns the int value of theJsonNumberat the specified position.JsonArraygetJsonArray(int index)Returns the array value at the specified position in this array.JsonNumbergetJsonNumber(int index)Returns the number value at the specified position in this array.JsonObjectgetJsonObject(int index)Returns the object value at the specified position in this array.JsonStringgetJsonString(int index)Returns the string value at ths specified position in this array.java.lang.StringgetString(int index)A convenience method forgetJsonString(index).getString().java.lang.StringgetString(int index, java.lang.String defaultValue)Returns theStringvalue ofJsonStringat the specified position in this JSON array values.<T extends JsonValue>
java.util.List<T>getValuesAs(java.lang.Class<T> clazz)Returns a list view of the specified type for the array.JsonValue.ValueTypegetValueType()Returns the value type of this JSON value.booleanisNull(int index)Returnstrueif the value at the specified location in this array isJsonValue.NULL.private java.lang.ObjectreadResolve()Preserves singleton propertyintsize()-
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jakarta.json.JsonArray
getValuesAs
-
Methods inherited from interface jakarta.json.JsonStructure
getValue
-
Methods inherited from interface jakarta.json.JsonValue
asJsonArray, asJsonObject, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
for serialization- See Also:
- Constant Field Values
-
-
Method Detail
-
get
public JsonValue get(int index)
-
size
public int size()
-
getJsonObject
public JsonObject getJsonObject(int index)
Description copied from interface:JsonArrayReturns the object value at the specified position in this array. This is a convenience method for(JsonObject)get(index).- Specified by:
getJsonObjectin interfaceJsonArray- Parameters:
index- index of the value to be returned- Returns:
- the value at the specified position in this array
-
getJsonArray
public JsonArray getJsonArray(int index)
Description copied from interface:JsonArrayReturns the array value at the specified position in this array. This is a convenience method for(JsonArray)get(index).- Specified by:
getJsonArrayin interfaceJsonArray- Parameters:
index- index of the value to be returned- Returns:
- the value at the specified position in this array
-
getJsonNumber
public JsonNumber getJsonNumber(int index)
Description copied from interface:JsonArrayReturns the number value at the specified position in this array. This is a convenience method for(JsonNumber)get(index).- Specified by:
getJsonNumberin interfaceJsonArray- Parameters:
index- index of the value to be returned- Returns:
- the value at the specified position in this array
-
getJsonString
public JsonString getJsonString(int index)
Description copied from interface:JsonArrayReturns the string value at ths specified position in this array. This is a convenience method for(JsonString)get(index).- Specified by:
getJsonStringin interfaceJsonArray- Parameters:
index- index of the value to be returned- Returns:
- the value at the specified position in this array
-
getValuesAs
public <T extends JsonValue> java.util.List<T> getValuesAs(java.lang.Class<T> clazz)
Description copied from interface:JsonArrayReturns a list view of the specified type for the array. This method does not verify if there is a value of wrong type in the array. Providing this typesafe view dynamically may cause a program fail with aClassCastException, if there is a value of wrong type in this array. Unfortunately, the exception can occur at any time after this method returns.- Specified by:
getValuesAsin interfaceJsonArray- Type Parameters:
T- The type of the List for the array- Parameters:
clazz- a JsonValue type- Returns:
- a list view of the specified type
-
getString
public java.lang.String getString(int index)
Description copied from interface:JsonArrayA convenience method forgetJsonString(index).getString().
-
getString
public java.lang.String getString(int index, java.lang.String defaultValue)Description copied from interface:JsonArrayReturns theStringvalue ofJsonStringat the specified position in this JSON array values. IfJsonStringis found, itsJsonString.getString()is returned. Otherwise, the specified default value is returned.
-
getInt
public int getInt(int index)
Description copied from interface:JsonArrayA convenience method forgetJsonNumber(index).intValue().
-
getInt
public int getInt(int index, int defaultValue)Description copied from interface:JsonArrayReturns the int value of theJsonNumberat the specified position. If the value at that position is aJsonNumber, this method returnsJsonNumber.intValue(). Otherwise this method returns the specified default value.
-
getBoolean
public boolean getBoolean(int index)
Description copied from interface:JsonArrayReturns the boolean value at the specified position. If the value at the specified position isJsonValue.TRUEthis method returnstrue. If the value at the specified position isJsonValue.FALSEthis method returnsfalse.- Specified by:
getBooleanin interfaceJsonArray- Parameters:
index- index of the JSON boolean value- Returns:
- the boolean value at the specified position
-
getBoolean
public boolean getBoolean(int index, boolean defaultValue)Description copied from interface:JsonArrayReturns the boolean value at the specified position. If the value at the specified position isJsonValue.TRUEthis method returnstrue. If the value at the specified position isJsonValue.FALSEthis method returnsfalse. Otherwise this method returns the specified default value.- Specified by:
getBooleanin interfaceJsonArray- Parameters:
index- index of the JSON boolean valuedefaultValue- the boolean value to return if theJsonValueat the specified position is neither TRUE nor FALSE- Returns:
- the boolean value at the specified position, or the specified default value
-
isNull
public boolean isNull(int index)
Description copied from interface:JsonArrayReturnstrueif the value at the specified location in this array isJsonValue.NULL.
-
getValueType
public JsonValue.ValueType getValueType()
Description copied from interface:JsonValueReturns the value type of this JSON value.- Specified by:
getValueTypein interfaceJsonValue- Returns:
- JSON value type
-
readResolve
private java.lang.Object readResolve()
Preserves singleton property- Returns:
JsonValue.EMPTY_JSON_ARRAY
-
-