- All Implemented Interfaces:
JsonArray
,JsonStructure
,JsonValue
,Serializable
,Iterable<JsonValue>
,Collection<JsonValue>
,List<JsonValue>
,RandomAccess
,SequencedCollection<JsonValue>
final class EmptyArray
extends AbstractList<JsonValue>
implements JsonArray, Serializable, RandomAccess
Private implementation of immutable
JsonArray
.-
Nested Class Summary
Nested classes/interfaces inherited from interface jakarta.json.JsonValue
JsonValue.ValueType
-
Field Summary
FieldsFields inherited from class java.util.AbstractList
modCount
Fields inherited from interface jakarta.json.JsonValue
EMPTY_JSON_ARRAY, EMPTY_JSON_OBJECT, FALSE, NULL, TRUE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget
(int index) boolean
getBoolean
(int index) Returns the boolean value at the specified position.boolean
getBoolean
(int index, boolean defaultValue) Returns the boolean value at the specified position.int
getInt
(int index) A convenience method forgetJsonNumber(index).intValue()
.int
getInt
(int index, int defaultValue) Returns the int value of theJsonNumber
at the specified position.getJsonArray
(int index) Returns the array value at the specified position in this array.getJsonNumber
(int index) Returns the number value at the specified position in this array.getJsonObject
(int index) Returns the object value at the specified position in this array.getJsonString
(int index) Returns the string value at ths specified position in this array.getString
(int index) A convenience method forgetJsonString(index).getString()
.Returns theString
value ofJsonString
at the specified position in this JSON array values.getValuesAs
(Class<T> clazz) Returns a list view of the specified type for the array.Returns the value type of this JSON value.boolean
isNull
(int index) Returnstrue
if the value at the specified location in this array isJsonValue.NULL
.private Object
Preserves singleton propertyint
size()
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 java.util.Collection
parallelStream, removeIf, stream, toArray
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
Methods inherited from interface java.util.List
add, add, addAll, addAll, addFirst, addLast, clear, contains, containsAll, equals, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, set, sort, spliterator, subList, toArray, toArray
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDfor serialization- See Also:
-
-
Constructor Details
-
EmptyArray
EmptyArray()Default constructor.
-
-
Method Details
-
get
-
size
public int size()- Specified by:
size
in interfaceCollection<JsonValue>
- Specified by:
size
in interfaceList<JsonValue>
- Specified by:
size
in classAbstractCollection<JsonValue>
-
getJsonObject
Description copied from interface:JsonArray
Returns the object value at the specified position in this array. This is a convenience method for(JsonObject)get(index)
.- Specified by:
getJsonObject
in interfaceJsonArray
- Parameters:
index
- index of the value to be returned- Returns:
- the value at the specified position in this array
-
getJsonArray
Description copied from interface:JsonArray
Returns the array value at the specified position in this array. This is a convenience method for(JsonArray)get(index)
.- Specified by:
getJsonArray
in interfaceJsonArray
- Parameters:
index
- index of the value to be returned- Returns:
- the value at the specified position in this array
-
getJsonNumber
Description copied from interface:JsonArray
Returns the number value at the specified position in this array. This is a convenience method for(JsonNumber)get(index)
.- Specified by:
getJsonNumber
in interfaceJsonArray
- Parameters:
index
- index of the value to be returned- Returns:
- the value at the specified position in this array
-
getJsonString
Description copied from interface:JsonArray
Returns the string value at ths specified position in this array. This is a convenience method for(JsonString)get(index)
.- Specified by:
getJsonString
in interfaceJsonArray
- Parameters:
index
- index of the value to be returned- Returns:
- the value at the specified position in this array
-
getValuesAs
Description copied from interface:JsonArray
Returns 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:
getValuesAs
in 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
Description copied from interface:JsonArray
A convenience method forgetJsonString(index).getString()
. -
getString
Description copied from interface:JsonArray
Returns theString
value ofJsonString
at the specified position in this JSON array values. IfJsonString
is found, itsJsonString.getString()
is returned. Otherwise, the specified default value is returned. -
getInt
public int getInt(int index) Description copied from interface:JsonArray
A convenience method forgetJsonNumber(index).intValue()
. -
getInt
public int getInt(int index, int defaultValue) Description copied from interface:JsonArray
Returns the int value of theJsonNumber
at 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:JsonArray
Returns the boolean value at the specified position. If the value at the specified position isJsonValue.TRUE
this method returnstrue
. If the value at the specified position isJsonValue.FALSE
this method returnsfalse
.- Specified by:
getBoolean
in 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:JsonArray
Returns the boolean value at the specified position. If the value at the specified position isJsonValue.TRUE
this method returnstrue
. If the value at the specified position isJsonValue.FALSE
this method returnsfalse
. Otherwise this method returns the specified default value.- Specified by:
getBoolean
in interfaceJsonArray
- Parameters:
index
- index of the JSON boolean valuedefaultValue
- the boolean value to return if theJsonValue
at 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:JsonArray
Returnstrue
if the value at the specified location in this array isJsonValue.NULL
. -
getValueType
Description copied from interface:JsonValue
Returns the value type of this JSON value.- Specified by:
getValueType
in interfaceJsonValue
- Returns:
- JSON value type
-
readResolve
Preserves singleton property- Returns:
JsonValue.EMPTY_JSON_ARRAY
-