Interface TomlArray

All Superinterfaces:
Iterable<TomlValue>, RandomAccess, TomlValue

@NonExtendable public interface TomlArray extends Iterable<TomlValue>, RandomAccess, TomlValue
A list of TOML values
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    add(boolean value)
    Adds a new element to this array after wrapping it into a TomlPrimitive
    default void
    add(double value)
    Adds a new element to this array after wrapping it into a TomlPrimitive
    default void
    add(float value)
    Adds a new element to this array after wrapping it into a TomlPrimitive
    default void
    add(int value)
    Adds a new element to this array after wrapping it into a TomlPrimitive
    default void
    add(long value)
    Adds a new element to this array after wrapping it into a TomlPrimitive
    default void
    add(@NotNull String value)
    Adds a new element to this array after wrapping it into a TomlPrimitive
    void
    add(TomlValue value)
    Adds a new element to this array
    default void
    addAll(@NotNull Iterable<? extends TomlValue> source)
    Adds to this array all the values contained within source
    default boolean
    Returns true if the given value is present within the array
    static @NotNull TomlArray
    copyOf(@NotNull Iterable<? extends TomlValue> array)
    Creates a new mutable TomlArray with the same content as the provided array
    static @NotNull TomlArray
    Creates a new empty TomlArray
    static @NotNull TomlArray
    create(int initialCapacity)
    Creates a new TomlArray with the specified initial capacity
    @NotNull TomlValue
    get(int index)
    Returns the Nth element in this array
    remove(int index)
    Removes the Nth element from this array
    default boolean
    Removes the first occurrence of the specified value from this array
    @NotNull TomlValue
    set(int index, TomlValue value)
    Sets the Nth element of this array to the given value
    int
    Reports the number of elements in this array
    default @NotNull TomlValue @NotNull []
    Returns a new array with the same length and values as this object
    default <T extends TomlValue>
    @NotNull T @NotNull []
    toArray(@NotNull Class<T> valueType)
    Returns a new array with the same length and values as this object, asserting that each element is an instance of the given class

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator

    Methods inherited from interface io.github.wasabithumb.jtoml.value.TomlValue

    asArray, asPrimitive, asTable, comments, creationTime, flags, flags, isArray, isPrimitive, isTable
  • Method Details

    • create

      @Contract("_ -> new") @NotNull static @NotNull TomlArray create(int initialCapacity)
      Creates a new TomlArray with the specified initial capacity
    • create

      @Contract("-> new") @NotNull static @NotNull TomlArray create()
      Creates a new empty TomlArray
    • copyOf

      @Contract("_ -> new") @AvailableSince("0.6.3") @NotNull static @NotNull TomlArray copyOf(@NotNull @NotNull Iterable<? extends TomlValue> array)
      Creates a new mutable TomlArray with the same content as the provided array
    • size

      @Contract(pure=true) int size()
      Reports the number of elements in this array
    • get

      @NotNull @NotNull TomlValue get(int index) throws IndexOutOfBoundsException
      Returns the Nth element in this array
      Throws:
      IndexOutOfBoundsException - Index is less than 0 or not less than size()
    • add

      @Contract(value="null -> fail", mutates="this") void add(TomlValue value)
      Adds a new element to this array
      Throws:
      NullPointerException - Value is null
    • add

      @Contract(mutates="this") default void add(@NotNull @NotNull String value)
      Adds a new element to this array after wrapping it into a TomlPrimitive
      Throws:
      NullPointerException - Value is null
      See Also:
    • add

      @Contract(mutates="this") default void add(boolean value)
      Adds a new element to this array after wrapping it into a TomlPrimitive
      See Also:
    • add

      @Contract(mutates="this") default void add(long value)
      Adds a new element to this array after wrapping it into a TomlPrimitive
      See Also:
    • add

      @Contract(mutates="this") default void add(int value)
      Adds a new element to this array after wrapping it into a TomlPrimitive
      See Also:
    • add

      @Contract(mutates="this") default void add(double value)
      Adds a new element to this array after wrapping it into a TomlPrimitive
      See Also:
    • add

      @Contract(mutates="this") default void add(float value)
      Adds a new element to this array after wrapping it into a TomlPrimitive
      See Also:
    • addAll

      default void addAll(@NotNull @NotNull Iterable<? extends TomlValue> source)
      Adds to this array all the values contained within source
    • contains

      @Contract("null -> false") default boolean contains(TomlValue value)
      Returns true if the given value is present within the array
    • remove

      @Contract(value="_ -> !null", mutates="this") TomlValue remove(int index) throws IndexOutOfBoundsException
      Removes the Nth element from this array
      Returns:
      The element that was removed
      Throws:
      IndexOutOfBoundsException - Index is less than 0 or not less than size()
    • remove

      @Contract(value="null -> false", mutates="this") default boolean remove(TomlValue value)
      Removes the first occurrence of the specified value from this array
      Returns:
      True if any element was removed
    • set

      @Contract(value="_, null -> fail", mutates="this") @NotNull @NotNull TomlValue set(int index, TomlValue value) throws IndexOutOfBoundsException
      Sets the Nth element of this array to the given value
      Returns:
      The value previously set at this index
      Throws:
      IndexOutOfBoundsException - Index is less than 0 or not less than size()
    • toArray

      @Contract("-> new") @NotNull default @NotNull TomlValue @NotNull [] toArray()
      Returns a new array with the same length and values as this object
    • toArray

      @Contract("_ -> new") @NotNull default <T extends TomlValue> @NotNull T @NotNull [] toArray(@NotNull @NotNull Class<T> valueType) throws ClassCastException
      Returns a new array with the same length and values as this object, asserting that each element is an instance of the given class
      Throws:
      ClassCastException - One or more elements could not be cast to the given type