Interface JsonArray

All Superinterfaces:
JsonElement<JsonArray>, de.espirit.firstspirit.json.JsonOutput

@NonExtendable @Experimental public interface JsonArray extends JsonElement<JsonArray>
The interface for json arrays. CAUTION: This class is still in development and may change drastically without any further notice.
Since:
5.2.191206
See Also:
  • JsonOutput
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final char
    The default delimiter of an array in json '{'.
    static final char
    The default prefix of an array in json '['.
    static final char
    The default suffix of an array in json ']'.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull JsonArray
    add(@NotNull JsonElement<?>... values)
    This method adds one or more elements to the list.
    @NotNull JsonArray
    add(@NotNull Collection<? extends JsonElement<?>> values)
    This method adds a collection of JsonElement instances to the list.
    static JsonArray
    Create a new empty JsonArray.
    @NotNull JsonElement<?>
    get(int index)
    Returns the element at the specified position in this array.
    @NotNull JsonArray
    remove(@NotNull JsonElement<?>... values)
    This method removes the given {link JsonElement elements}.
    @NotNull JsonArray
    remove(@NotNull Collection<? extends JsonElement<?>> values)
    This method removes a collection of JsonElement instances from the list.
    int
    Returns the number of elements in this list.
    default @NotNull Stream<JsonElement<?>>
    This method transforms the current values list to a stream and returns it.
    @NotNull Collection<JsonElement<?>>
    Returns the current values in a new collection.

    Methods inherited from interface de.espirit.firstspirit.json.JsonElement

    getValue

    Methods inherited from interface de.espirit.firstspirit.json.JsonOutput

    json, writeTo
  • Field Details

    • PREFIX

      static final char PREFIX
      The default prefix of an array in json '['.
      Since:
      5.2.191206
      See Also:
    • DELIMITER

      static final char DELIMITER
      The default delimiter of an array in json '{'.
      Since:
      5.2.191206
      See Also:
    • SUFFIX

      static final char SUFFIX
      The default suffix of an array in json ']'.
      Since:
      5.2.191206
      See Also:
  • Method Details

    • create

      static JsonArray create()
      Create a new empty JsonArray.
      Returns:
      a new JsonArray
      Since:
      5.2.191206
    • add

      @NotNull @NotNull JsonArray add(@NotNull @NotNull JsonElement<?>... values)
      This method adds one or more elements to the list.
      Parameters:
      values - The value(s) that should be added to the list (must not be null).
      Returns:
      The list itself to do more actions if needed.
      Since:
      5.2.191206
    • add

      @NotNull @NotNull JsonArray add(@NotNull @NotNull Collection<? extends JsonElement<?>> values)
      This method adds a collection of JsonElement instances to the list.
      Parameters:
      values - The collection that holds the values that should be added (must not be null).
      Returns:
      The list itself to do more actions if needed.
      Since:
      5.2.191206
    • remove

      @NotNull @NotNull JsonArray remove(@NotNull @NotNull JsonElement<?>... values)
      This method removes the given {link JsonElement elements}.
      Parameters:
      values - The value(s) that should be removed from the list.
      Returns:
      The list itself to do more actions if needed.
      Since:
      5.2.191206
    • remove

      @NotNull @NotNull JsonArray remove(@NotNull @NotNull Collection<? extends JsonElement<?>> values)
      This method removes a collection of JsonElement instances from the list.
      Parameters:
      values - The collection that holds the values that should be removed.
      Returns:
      The list itself to do more actions if needed.
      Since:
      5.2.191206
    • get

      @NotNull @NotNull JsonElement<?> get(int index)
      Returns the element at the specified position in this array.
      Parameters:
      index - index of the element to return
      Returns:
      the element at the specified position in this array
      Throws:
      IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())
      Since:
      5.2.191206
    • values

      @NotNull @NotNull Collection<JsonElement<?>> values()
      Returns the current values in a new collection.
      NOTE:
      Modifying the returned collection will not modify the values of this array. If you want to modify the values of this array you must use methods of this class.

      However, modifying the elements will modify the actual elements.

      Returns:
      a new collection containing the current values
      Since:
      5.2.191206
      See Also:
    • size

      int size()
      Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
      Returns:
      the number of elements in this list
      Since:
      5.2.191206
    • stream

      @NotNull default @NotNull Stream<JsonElement<?>> stream()
      This method transforms the current values list to a stream and returns it.
      Returns:
      A sequential Stream over the elements in this JsonArray
      Since:
      5.2.191206