Interface TomlArray
- All Superinterfaces:
Iterable<TomlValue>,RandomAccess,TomlValue
A list of
TOML values- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidadd(boolean value) Adds a new element to this array after wrapping it into aTomlPrimitivedefault voidadd(double value) Adds a new element to this array after wrapping it into aTomlPrimitivedefault voidadd(float value) Adds a new element to this array after wrapping it into aTomlPrimitivedefault voidadd(int value) Adds a new element to this array after wrapping it into aTomlPrimitivedefault voidadd(long value) Adds a new element to this array after wrapping it into aTomlPrimitivedefault voidAdds a new element to this array after wrapping it into aTomlPrimitivevoidAdds a new element to this arraydefault voidAdds to this array all the values contained withinsourcedefault booleanReturns true if the given value is present within the arraystatic @NotNull TomlArrayCreates a new mutable TomlArray with the same content as the provided arraystatic @NotNull TomlArraycreate()Creates a new empty TomlArraystatic @NotNull TomlArraycreate(int initialCapacity) Creates a new TomlArray with the specified initial capacity@NotNull TomlValueget(int index) Returns the Nth element in this arrayremove(int index) Removes the Nth element from this arraydefault booleanRemoves the first occurrence of the specified value from this array@NotNull TomlValueSets the Nth element of this array to the given valueintsize()Reports the number of elements in this arraydefault @NotNull TomlValue @NotNull []toArray()Returns a new array with the same length and values as this objectdefault <T extends TomlValue>
@NotNull T @NotNull []Returns a new array with the same length and values as this object, asserting that each element is an instance of the given classMethods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface io.github.wasabithumb.jtoml.value.TomlValue
asArray, asPrimitive, asTable, comments, creationTime, flags, flags, isArray, isPrimitive, isTable
-
Method Details
-
create
Creates a new TomlArray with the specified initial capacity -
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
Returns the Nth element in this array- Throws:
IndexOutOfBoundsException- Index is less than 0 or not less thansize()
-
add
Adds a new element to this array- Throws:
NullPointerException- Value is null
-
add
Adds a new element to this array after wrapping it into aTomlPrimitive- 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 aTomlPrimitive- See Also:
-
add
@Contract(mutates="this") default void add(long value) Adds a new element to this array after wrapping it into aTomlPrimitive- See Also:
-
add
@Contract(mutates="this") default void add(int value) Adds a new element to this array after wrapping it into aTomlPrimitive- See Also:
-
add
@Contract(mutates="this") default void add(double value) Adds a new element to this array after wrapping it into aTomlPrimitive- See Also:
-
add
@Contract(mutates="this") default void add(float value) Adds a new element to this array after wrapping it into aTomlPrimitive- See Also:
-
addAll
Adds to this array all the values contained withinsource -
contains
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 thansize()
-
remove
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 thansize()
-
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
-