Interface ListBinaryTag

All Superinterfaces:
BinaryTag, BinaryTagLike, Iterable<BinaryTag>, ListTagSetter<ListBinaryTag,BinaryTag>

public sealed interface ListBinaryTag extends ListTagSetter<ListBinaryTag,BinaryTag>, BinaryTag, Iterable<BinaryTag>
A list of a single tag type.
Since:
4.0.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    A list tag builder.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a builder.
    builder(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a builder with the specified initial capacity.
    static <T extends BinaryTag>
    ListBinaryTag.Builder<T>
    Creates a builder.
    static <T extends BinaryTag>
    ListBinaryTag.Builder<T>
    builder(BinaryTagType<T> type, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a builder with the specified initial capacity.
    Gets the type of element stored in this list.
    Gets an empty list tag.
    from(Iterable<? extends BinaryTag> tags)
    Creates a list tag from tags.
    get(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
    Gets a tag.
    default byte
    getByte(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
    Gets a byte.
    default byte
    getByte(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, byte defaultValue)
    Gets a byte.
    default byte[]
    getByteArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
    Gets an array of bytes.
    default byte @Nullable []
    getByteArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, byte @Nullable [] defaultValue)
    Gets an array of bytes.
    getCompound(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
    Gets a compound.
    default @Nullable CompoundBinaryTag
    getCompound(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @Nullable CompoundBinaryTag defaultValue)
    Gets a compound.
    default double
    getDouble(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
    Gets a double.
    default double
    getDouble(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, double defaultValue)
    Gets a double.
    default float
    getFloat(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
    Gets a float.
    default float
    getFloat(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, float defaultValue)
    Gets a float.
    default int
    getInt(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
    Gets an int.
    default int
    getInt(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, int defaultValue)
    Gets an int.
    default int[]
    getIntArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
    Gets an array of ints.
    default int @Nullable []
    getIntArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, int @Nullable [] defaultValue)
    Gets an array of ints.
    getList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
    Gets a list.
    getList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @Nullable BinaryTagType<?> elementType)
    Gets a list.
    default @Nullable ListBinaryTag
    getList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @Nullable BinaryTagType<?> elementType, @Nullable ListBinaryTag defaultValue)
    Gets a list.
    default @Nullable ListBinaryTag
    getList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @Nullable ListBinaryTag defaultValue)
    Gets a list.
    default long
    getLong(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
    Gets a long.
    default long
    getLong(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, long defaultValue)
    Gets a long.
    default long[]
    getLongArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
    Gets an array of longs.
    default long @Nullable []
    getLongArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, long @Nullable [] defaultValue)
    Gets an array of longs.
    default short
    getShort(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
    Gets a short.
    default short
    getShort(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, short defaultValue)
    Gets a short.
    default String
    getString(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
    Gets a string.
    default @Nullable String
    getString(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @Nullable String defaultValue)
    Gets a string.
    Creates a builder that can accept elements of multiple types.
    heterogeneousListBinaryTag(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
    Creates a builder with the specified initial capacity that can accept elements of multiple types.
    boolean
    Returns whether the list has elements or not.
    Creates a tag.
    remove(int index, @Nullable Consumer<? super BinaryTag> removed)
    Removes the tag at index index, optionally providing removedConsumer with the tag previously at index index.
    set(int index, BinaryTag tag, @Nullable Consumer<? super BinaryTag> removed)
    Sets the tag at index index to tag, optionally providing removedConsumer with the tag previously at index index.
    int
    Gets the size.
    Creates a stream of the tags contained within this list.
    Create a Collector to consume streams of list tags.
    toListTag(@Nullable ListBinaryTag initial)
    Create a Collector to consume streams of map entries, with initial contents.
    Gets the tag type.
    Unwrap any compound-boxed heterogeneous values in this tag.
    Wrap any heterogeneous values in this tag into compound-tag boxes.

    Methods inherited from interface net.kyori.adventure.nbt.BinaryTag

    asBinaryTag

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator

    Methods inherited from interface net.kyori.adventure.nbt.ListTagSetter

    add, add
  • Method Details

    • empty

      static ListBinaryTag empty()
      Gets an empty list tag.
      Returns:
      an empty tag
      Since:
      4.0.0
    • from

      static ListBinaryTag from(Iterable<? extends BinaryTag> tags)
      Creates a list tag from tags.

      The element type of the returned list tag is determined from tags.

      Parameters:
      tags - the list of contents for the created tag
      Returns:
      a list tag
      Throws:
      IllegalArgumentException - if tags has different tag types within
      Since:
      4.4.0
    • builder

      static ListBinaryTag.Builder<BinaryTag> builder()
      Creates a builder.
      Returns:
      a new builder
      Since:
      4.0.0
    • builder

      static ListBinaryTag.Builder<BinaryTag> builder(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a builder with the specified initial capacity.
      Parameters:
      initialCapacity - the initial capacity
      Returns:
      a new builder
      Since:
      4.25.0
    • heterogeneousListBinaryTag

      static ListBinaryTag.Builder<BinaryTag> heterogeneousListBinaryTag()
      Creates a builder that can accept elements of multiple types.
      Returns:
      a new builder
      Since:
      4.21.0
    • heterogeneousListBinaryTag

      static ListBinaryTag.Builder<BinaryTag> heterogeneousListBinaryTag(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a builder with the specified initial capacity that can accept elements of multiple types.
      Parameters:
      initialCapacity - the initial capacity
      Returns:
      a new builder
      Since:
      4.25.0
    • builder

      static <T extends BinaryTag> ListBinaryTag.Builder<T> builder(BinaryTagType<T> type)
      Creates a builder.
      Type Parameters:
      T - the element type
      Parameters:
      type - the element type
      Returns:
      a new builder
      Throws:
      IllegalArgumentException - if type is BinaryTagTypes.END
      Since:
      4.0.0
    • builder

      static <T extends BinaryTag> ListBinaryTag.Builder<T> builder(BinaryTagType<T> type, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int initialCapacity)
      Creates a builder with the specified initial capacity.
      Type Parameters:
      T - the element type
      Parameters:
      type - the element type
      initialCapacity - the initial capacity
      Returns:
      a new builder
      Throws:
      IllegalArgumentException - if type is BinaryTagTypes.END
      Since:
      4.25.0
    • listBinaryTag

      static ListBinaryTag listBinaryTag(BinaryTagType<? extends BinaryTag> type, List<BinaryTag> tags)
      Creates a tag.

      If tags is empty, empty() will be returned.

      Parameters:
      type - the element type
      tags - the elements
      Returns:
      a tag
      Throws:
      IllegalArgumentException - if type is BinaryTagTypes.END, or if elements are of different types
      Since:
      4.14.0
    • toListTag

      static Collector<BinaryTag,?,ListBinaryTag> toListTag()
      Create a Collector to consume streams of list tags.
      Returns:
      a collector of tags
      Since:
      4.21.0
    • toListTag

      static Collector<BinaryTag,?,ListBinaryTag> toListTag(@Nullable ListBinaryTag initial)
      Create a Collector to consume streams of map entries, with initial contents.

      In the event of duplicate entries, the last seen entry will be preserved.

      Parameters:
      initial - an existing tag that will initialize the builder
      Returns:
      a collector for map entries
      Since:
      4.21.0
    • type

      default BinaryTagType<ListBinaryTag> type()
      Description copied from interface: BinaryTag
      Gets the tag type.
      Specified by:
      type in interface BinaryTag
      Returns:
      the tag type
    • elementType

      BinaryTagType<? extends BinaryTag> elementType()
      Gets the type of element stored in this list.
      Returns:
      the type
      Since:
      4.4.0
    • size

      int size()
      Gets the size.
      Returns:
      the size
      Since:
      4.0.0
    • isEmpty

      boolean isEmpty()
      Returns whether the list has elements or not.
      Returns:
      false if the list has elements
      Since:
      4.18.0
    • get

      BinaryTag get(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
      Gets a tag.
      Parameters:
      index - the index
      Returns:
      the tag
      Throws:
      IndexOutOfBoundsException - if the index is out of range
      Since:
      4.0.0
    • set

      ListBinaryTag set(int index, BinaryTag tag, @Nullable Consumer<? super BinaryTag> removed)
      Sets the tag at index index to tag, optionally providing removedConsumer with the tag previously at index index.
      Parameters:
      index - the index
      tag - the tag
      removed - a consumer which receives the tag being removed at index index
      Returns:
      a list tag
      Since:
      4.0.0
    • remove

      ListBinaryTag remove(int index, @Nullable Consumer<? super BinaryTag> removed)
      Removes the tag at index index, optionally providing removedConsumer with the tag previously at index index.
      Parameters:
      index - the index
      removed - a consumer which receives the tag being removed at index index
      Returns:
      a list tag
      Since:
      4.0.0
    • getByte

      default byte getByte(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
      Gets a byte.
      Parameters:
      index - the index
      Returns:
      the byte value, or 0
      Since:
      4.0.0
    • getByte

      default byte getByte(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, byte defaultValue)
      Gets a byte.
      Parameters:
      index - the index
      defaultValue - the default value
      Returns:
      the byte value, or defaultValue
      Since:
      4.0.0
    • getShort

      default short getShort(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
      Gets a short.
      Parameters:
      index - the index
      Returns:
      the short value, or 0
      Since:
      4.0.0
    • getShort

      default short getShort(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, short defaultValue)
      Gets a short.
      Parameters:
      index - the index
      defaultValue - the default value
      Returns:
      the short value, or defaultValue
      Since:
      4.0.0
    • getInt

      default int getInt(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
      Gets an int.
      Parameters:
      index - the index
      Returns:
      the int value, or 0
      Since:
      4.0.0
    • getInt

      default int getInt(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, int defaultValue)
      Gets an int.
      Parameters:
      index - the index
      defaultValue - the default value
      Returns:
      the int value, or defaultValue
      Since:
      4.0.0
    • getLong

      default long getLong(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
      Gets a long.
      Parameters:
      index - the index
      Returns:
      the long value, or 0
      Since:
      4.0.0
    • getLong

      default long getLong(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, long defaultValue)
      Gets a long.
      Parameters:
      index - the index
      defaultValue - the default value
      Returns:
      the long value, or defaultValue
      Since:
      4.0.0
    • getFloat

      default float getFloat(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
      Gets a float.
      Parameters:
      index - the index
      Returns:
      the float value, or 0
      Since:
      4.0.0
    • getFloat

      default float getFloat(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, float defaultValue)
      Gets a float.
      Parameters:
      index - the index
      defaultValue - the default value
      Returns:
      the float value, or defaultValue
      Since:
      4.0.0
    • getDouble

      default double getDouble(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
      Gets a double.
      Parameters:
      index - the index
      Returns:
      the double value, or 0
      Since:
      4.0.0
    • getDouble

      default double getDouble(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, double defaultValue)
      Gets a double.
      Parameters:
      index - the index
      defaultValue - the default value
      Returns:
      the double value, or defaultValue
      Since:
      4.0.0
    • getByteArray

      default byte[] getByteArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
      Gets an array of bytes.
      Parameters:
      index - the index
      Returns:
      the array of bytes, or a zero-length array
      Since:
      4.0.0
    • getByteArray

      @Contract("_, !null -> !null") default byte @Nullable [] getByteArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, byte @Nullable [] defaultValue)
      Gets an array of bytes.
      Parameters:
      index - the index
      defaultValue - the default value
      Returns:
      the array of bytes, or defaultValue
      Since:
      4.0.0
    • getString

      default String getString(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
      Gets a string.
      Parameters:
      index - the index
      Returns:
      the string value, or ""
      Since:
      4.0.0
    • getString

      @Contract("_, !null -> !null") default @Nullable String getString(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @Nullable String defaultValue)
      Gets a string.
      Parameters:
      index - the index
      defaultValue - the default value
      Returns:
      the string value, or defaultValue
      Since:
      4.0.0
    • getList

      default ListBinaryTag getList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
      Gets a list.
      Parameters:
      index - the index
      Returns:
      the list, or an empty list if the tag at index index is not a list tag
      Since:
      4.4.0
    • getList

      default ListBinaryTag getList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @Nullable BinaryTagType<?> elementType)
      Gets a list.
      Parameters:
      index - the index
      elementType - the expected element type of the list at index index
      Returns:
      the list, or an empty list if the tag at index index is not a list tag, or if the list tag's element type is not elementType
      Since:
      4.4.0
    • getList

      @Contract("_, !null -> !null") default @Nullable ListBinaryTag getList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @Nullable ListBinaryTag defaultValue)
      Gets a list.
      Parameters:
      index - the index
      defaultValue - the default value
      Returns:
      the list, or defaultValue if the tag at index index is not a list tag
      Since:
      4.4.0
    • getList

      @Contract("_, _, !null -> !null") default @Nullable ListBinaryTag getList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @Nullable BinaryTagType<?> elementType, @Nullable ListBinaryTag defaultValue)
      Gets a list.

      If elementType is non-null and the ListBinaryTag at index index does not match, defaultValue will be returned.

      Parameters:
      index - the index
      elementType - the expected element type of the list at index index
      defaultValue - the default value
      Returns:
      the list, or defaultValue if the tag at index index is not a list tag, or if the list tag's element type is not elementType
      Since:
      4.4.0
    • getCompound

      default CompoundBinaryTag getCompound(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
      Gets a compound.
      Parameters:
      index - the index
      Returns:
      the compound, or a new compound
      Since:
      4.0.0
    • getCompound

      @Contract("_, !null -> !null") default @Nullable CompoundBinaryTag getCompound(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @Nullable CompoundBinaryTag defaultValue)
      Gets a compound.
      Parameters:
      index - the index
      defaultValue - the default value
      Returns:
      the compound, or defaultValue
      Since:
      4.0.0
    • getIntArray

      default int[] getIntArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
      Gets an array of ints.
      Parameters:
      index - the index
      Returns:
      the array of ints, or a zero-length array
      Since:
      4.0.0
    • getIntArray

      @Contract("_, !null -> !null") default int @Nullable [] getIntArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, int @Nullable [] defaultValue)
      Gets an array of ints.
      Parameters:
      index - the index
      defaultValue - the default value
      Returns:
      the array of ints, or defaultValue
      Since:
      4.0.0
    • getLongArray

      default long[] getLongArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index)
      Gets an array of longs.
      Parameters:
      index - the index
      Returns:
      the array of longs, or a zero-length array
      Since:
      4.0.0
    • getLongArray

      @Contract("_, !null -> !null") default long @Nullable [] getLongArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, long @Nullable [] defaultValue)
      Gets an array of longs.
      Parameters:
      index - the index
      defaultValue - the default value
      Returns:
      the array of longs, or defaultValue
      Since:
      4.0.0
    • stream

      Stream<BinaryTag> stream()
      Creates a stream of the tags contained within this list.
      Returns:
      a new stream
      Since:
      4.2.0
    • unwrapHeterogeneity

      ListBinaryTag unwrapHeterogeneity()
      Unwrap any compound-boxed heterogeneous values in this tag.
      Returns:
      a list tag that permits heterogeneity
      Since:
      4.21.0
    • wrapHeterogeneity

      ListBinaryTag wrapHeterogeneity()
      Wrap any heterogeneous values in this tag into compound-tag boxes.
      Returns:
      a list tag that does not permit heterogeneity, with any heterogeneous values boxed if necessary
      Since:
      4.21.0