Interface JsonArrayBuilder

All Superinterfaces:
Iterable<JsonValue>, JsonValueContainer<JsonValue>

public interface JsonArrayBuilder extends JsonValueContainer<JsonValue>
A mutable builder with a fluent API for a JsonArray. Implementations of this interface are normally not thread safe and not reusable.
  • Method Details

    • add

      JsonArrayBuilder add(int value, int... furtherValues)
      Adds at least new int value to the JSON array to be built.
      Parameters:
      value - the int to add to the array.
      furtherValues - additional values to be added to the array.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if furtherValues is null.
    • addIntegers

      JsonArrayBuilder addIntegers(Iterable<Integer> intValues)
      Adds all given values to the array to be built.
      Parameters:
      intValues - the values to be added.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if intValues is null.
    • set

      JsonArrayBuilder set(int index, int value)
      Replaces the value at the specified position in the array to be built.
      Parameters:
      index - the position of the element to be set.
      value - the value to be placed at the specified position.
      Returns:
      this builder to allow method chaining.
      Throws:
      IndexOutOfBoundsException - if the index is out of range, i. e. index < 0 || index > getSize()
    • add

      JsonArrayBuilder add(long value, long... furtherValues)
      Adds at least one long value to the JSON array to be built.
      Parameters:
      value - the long to add to the array.
      furtherValues - additional values to be added to the array.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if furtherValues is null.
    • addLongs

      JsonArrayBuilder addLongs(Iterable<Long> longValues)
      Adds all given values to the array to be built.
      Parameters:
      longValues - the values to be added.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if longValues is null.
    • set

      JsonArrayBuilder set(int index, long value)
      Replaces the value at the specified position in the array to be built.
      Parameters:
      index - the position of the element to be set.
      value - the value to be placed at the specified position.
      Returns:
      this builder to allow method chaining.
      Throws:
      IndexOutOfBoundsException - if the index is out of range, i. e. index < 0 || index > getSize()
    • add

      JsonArrayBuilder add(double value, double... furtherValues)
      Adds at least one double value to the JSON array to be built.
      Parameters:
      value - the double to add to the array.
      furtherValues - additional values to be added to the array.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if furtherValues is null.
    • addDoubles

      JsonArrayBuilder addDoubles(Iterable<Double> doubleValues)
      Adds all given values to the array to be built.
      Parameters:
      doubleValues - the values to be added.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if doubleValues is null.
    • set

      JsonArrayBuilder set(int index, double value)
      Replaces the value at the specified position in the array to be built.
      Parameters:
      index - the position of the element to be set.
      value - the value to be placed at the specified position.
      Returns:
      this builder to allow method chaining.
      Throws:
      IndexOutOfBoundsException - if the index is out of range, i. e. index < 0 || index > getSize()
    • add

      JsonArrayBuilder add(boolean value, boolean... furtherValues)
      Adds at least one boolean value to the array to be built.
      Parameters:
      value - the boolean to add to the array.
      furtherValues - additional values to be added to the array.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if furtherValues is null.
    • addBooleans

      JsonArrayBuilder addBooleans(Iterable<Boolean> booleanValues)
      Adds all given values to the array to be built.
      Parameters:
      booleanValues - the values to be added.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if booleanValues is null.
    • set

      JsonArrayBuilder set(int index, boolean value)
      Replaces the value at the specified position in the array to be built.
      Parameters:
      index - the position of the element to be set.
      value - the value to be placed at the specified position.
      Returns:
      this builder to allow method chaining.
      Throws:
      IndexOutOfBoundsException - if the index is out of range, i. e. index < 0 || index > getSize()
    • add

      JsonArrayBuilder add(String value, String... furtherValues)
      Adds at least one string value to the array to be built.
      Parameters:
      value - the string to add to the array.
      furtherValues - additional values to be added to the array.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if any argument is null.
    • addStrings

      JsonArrayBuilder addStrings(Iterable<String> stringValues)
      Adds all given values to the array to be built.
      Parameters:
      stringValues - the values to be added.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if stringValues is null.
    • set

      JsonArrayBuilder set(int index, String value)
      Replaces the value at the specified position in the array to be built.
      Parameters:
      index - the position of the element to be set.
      value - the value to be placed at the specified position.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if value is null.
      IndexOutOfBoundsException - if the index is out of range, i. e. index < 0 || index > getSize()
    • add

      JsonArrayBuilder add(JsonValue value, JsonValue... furtherValues)
      Adds at least one JsonValue to the array to be built.
      Parameters:
      value - the JSON value to add to the array.
      furtherValues - additional values to be added to the array.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if any argument is null.
    • addAll

      JsonArrayBuilder addAll(Iterable<? extends JsonValue> values)
      Adds all given values to the array to be built.
      Parameters:
      values - the values to add to the array.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if values is null.
    • set

      JsonArrayBuilder set(int index, JsonValue value)
      Replaces the value at the specified position in the array to be built.
      Parameters:
      index - the position of the element to be set.
      value - the value to be placed at the specified position.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if value is null.
      IndexOutOfBoundsException - if the index is out of range, i. e. index < 0 || index > getSize()
    • get

      Optional<JsonValue> get(int index)
      Returns the JSON value at the specified position in the array to be built.
      Parameters:
      index - the index of the array value to be returned. If the index is out of bounds an empty Optional is returned.
      Returns:
      the JSON value at the specified position.
    • remove

      JsonArrayBuilder remove(int index)
      Removes the value at the specified position from the array to be built. This shifts any subsequent values to the left (lowers their indices by one).
      Parameters:
      index - the index of the value to be removed.
      Returns:
      this builder to allow method chaining.
      Throws:
      IndexOutOfBoundsException - if the index is out of range, i. e. index < 0 || index > getSize()
    • remove

      JsonArrayBuilder remove(JsonValue value)
      Removes the given value from the array to be built.
      Parameters:
      value - the value to be removed.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if value is null.
    • build

      JsonArray build()
      Creates a new JsonArray containing all values which were added beforehand.
      Returns:
      a new JSON array.