public final class JsonArray extends AbstractList<JsonValue> implements JsonValue
JsonValue.EntityType
modCount
Modifier and Type | Method and Description |
---|---|
JsonArray |
asJsonArray()
Returns this value as
JsonArray . |
boolean |
equals(Object otherObject)
Compares the specified object with this JSON array for equality.
|
JsonValue |
get(int index)
Returns the JSON value at the specified position in this array.
|
JsonValue.EntityType |
getEntityType()
Returns
JsonValue.EntityType.ARRAY , which is the entity type of JsonArray . |
int |
hashCode()
Returns the hash code value for this JSON array.
|
static JsonArray |
of()
Returns a JSON array containing zero JSON values.
|
static JsonArray |
of(JsonValue... values)
Returns a JSON array containing an arbitrary number of JSON values.
|
static JsonArray |
ofList(List<? extends JsonValue> values)
Returns a JSON array containing an arbitrary number of JSON values.
|
static JsonArray |
ofUnsafe(JsonValue... array)
Returns a JSON array containing the specified array as its internal representation.
|
int |
presumeReferenceSizeInBytes()
Returns the approximate size of this JSON array in bytes presumed to occupy in
Page as a reference. |
int |
size()
Returns the number of JSON values in this array.
|
String |
toJson()
Returns the stringified JSON representation of this JSON array.
|
org.msgpack.value.Value |
toMsgpack()
Deprecated.
Do not use this method. It is to be removed at some point after Embulk v1.0.0.
It is here only to ensure a migration period from MessagePack-based JSON values to new
JSON values of
JsonValue . |
String |
toString()
Returns the string representation of this JSON array.
|
add, add, addAll, clear, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
asJsonBoolean, asJsonDouble, asJsonLong, asJsonNull, asJsonObject, asJsonString, fromMsgpack, isJsonArray, isJsonBoolean, isJsonDouble, isJsonLong, isJsonNull, isJsonObject, isJsonString
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
parallelStream, removeIf, stream
public static JsonArray of()
public static JsonArray of(JsonValue... values)
values
- the JSON values to be contained in the JSON array, not nullNullPointerException
- if the array, or any value is null
public static JsonArray ofList(List<? extends JsonValue> values)
values
- the JSON values to be contained in the JSON array, not nullNullPointerException
- if the list, or any value is null
public static JsonArray ofUnsafe(JsonValue... array)
This method is not safe. If the specified array is modified after creating a JsonArray
instance with this method, the created JsonArray
instance can unintentionally behave differently.
It has no null
checks. If the specified array is null
, or contains null
,
the created JsonArray
can behave unexpectedly.
array
- the array of JSON values to be the internal representation as-is in the new JsonArray
public JsonValue.EntityType getEntityType()
JsonValue.EntityType.ARRAY
, which is the entity type of JsonArray
.getEntityType
in interface JsonValue
JsonValue.EntityType.ARRAY
, which is the entity type of JsonArray
public JsonArray asJsonArray()
JsonArray
.asJsonArray
in interface JsonValue
JsonArray
public int presumeReferenceSizeInBytes()
Page
as a reference.
This approximate size is used only as a threshold whether PageBuilder
is flushed, or not.
It is not accurate, it does not need to be accurate, and it is impossible in general to tell an accurate size that
a Java object occupies in the Java heap. But, a reasonable approximate would help to keep Page
performant in the Java heap.
It is better to flush more frequently for bigger JSON value objects, less often for smaller JSON value objects, but no infinite accumulation even for empty JSON value objects.
presumeReferenceSizeInBytes
in interface JsonValue
Page
as a referencepublic int size()
size
in interface Collection<JsonValue>
size
in interface List<JsonValue>
size
in class AbstractCollection<JsonValue>
public JsonValue get(int index)
get
in interface List<JsonValue>
get
in class AbstractList<JsonValue>
index
- index of the JSON value to returnIndexOutOfBoundsException
- If the index is out of range (index < 0 || index >= size()
)public String toJson()
@Deprecated public org.msgpack.value.Value toMsgpack()
JsonValue
.toMsgpack
in interface JsonValue
public String toString()
toString
in class AbstractCollection<JsonValue>
public boolean equals(Object otherObject)
Note that it can return true
only when JsonArray
is given. It checks the equality as a JSON array.
It does not return true
for a general List
even though the given list contains the same elements.
equals
in interface Collection<JsonValue>
equals
in interface List<JsonValue>
equals
in class AbstractList<JsonValue>
true
if the specified object is equal to this JSON arraypublic int hashCode()
hashCode
in interface Collection<JsonValue>
hashCode
in interface List<JsonValue>
hashCode
in class AbstractList<JsonValue>