Package net.kyori.adventure.nbt
Interface ListBinaryTag
- All Superinterfaces:
BinaryTag,BinaryTagLike,net.kyori.examination.Examinable,Iterable<BinaryTag>,ListTagSetter<ListBinaryTag,BinaryTag>
public interface ListBinaryTag
extends ListTagSetter<ListBinaryTag,BinaryTag>, BinaryTag, Iterable<BinaryTag>
A list of zero or more values of a single tag type.
- Since:
- 4.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceListBinaryTag.Builder<T extends BinaryTag>A list tag builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull ListBinaryTag.Builder<BinaryTag>builder()Creates a builder.static <T extends BinaryTag>
@NotNull ListBinaryTag.Builder<T>builder(@NotNull BinaryTagType<T> type) Creates a builder.@NotNull BinaryTagType<? extends BinaryTag>Gets the type of element stored in this list.static @NotNull ListBinaryTagempty()Gets an empty list tag.static @NotNull ListBinaryTagCreates a list tag fromtags.@NotNull BinaryTagget(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index) Gets a tag.default bytegetByte(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index) Gets a byte.default bytegetByte(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, byte defaultValue) Gets a byte.default byte @NotNull []getByteArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index) Gets an array of bytes.default byte @NotNull []getByteArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, byte @NotNull [] defaultValue) Gets an array of bytes.default @NotNull CompoundBinaryTaggetCompound(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index) Gets a compound.default @NotNull CompoundBinaryTaggetCompound(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @NotNull CompoundBinaryTag defaultValue) Gets a compound.default doublegetDouble(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index) Gets a double.default doublegetDouble(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, double defaultValue) Gets a double.default floatgetFloat(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index) Gets a float.default floatgetFloat(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, float defaultValue) Gets a float.default intgetInt(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index) Gets an int.default intgetInt(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, int defaultValue) Gets an int.default int @NotNull []getIntArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index) Gets an array of ints.default int @NotNull []getIntArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, int @NotNull [] defaultValue) Gets an array of ints.default @NotNull ListBinaryTaggetList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index) Gets a list.default @NotNull ListBinaryTaggetList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @NotNull ListBinaryTag defaultValue) Gets a list.default @NotNull ListBinaryTaggetList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @Nullable BinaryTagType<?> elementType) Gets a list.default @NotNull ListBinaryTaggetList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @Nullable BinaryTagType<?> elementType, @NotNull ListBinaryTag defaultValue) Gets a list.default longgetLong(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index) Gets a long.default longgetLong(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, long defaultValue) Gets a long.default long @NotNull []getLongArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index) Gets an array of longs.default long @NotNull []getLongArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, long @NotNull [] defaultValue) Gets an array of longs.default shortgetShort(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index) Gets a short.default shortgetShort(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, short defaultValue) Gets a short.default @NotNull StringgetString(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index) Gets a string.default @NotNull StringgetString(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @NotNull String defaultValue) Gets a string.static @NotNull ListBinaryTag.Builder<BinaryTag>Creates a builder that can accept elements of multiple types.booleanisEmpty()Returns whether the list has elements or not.static @NotNull ListBinaryTaglistBinaryTag(@NotNull BinaryTagType<? extends BinaryTag> type, @NotNull List<BinaryTag> tags) Creates a tag.default @NotNull BinaryTagType<? extends BinaryTag>listType()Deprecated.static @NotNull ListBinaryTagof(@NotNull BinaryTagType<? extends BinaryTag> type, @NotNull List<BinaryTag> tags) Deprecated.for removal since 4.14.0, uselistBinaryTag(BinaryTagType, List)instead.@NotNull ListBinaryTagRemoves the tag at indexindex, optionally providingremovedConsumerwith the tag previously at indexindex.@NotNull ListBinaryTagSets the tag at indexindextotag, optionally providingremovedConsumerwith the tag previously at indexindex.intsize()Gets the size.stream()Creates a stream of the tags contained within this list.static @NotNull Collector<BinaryTag,?, ListBinaryTag> Create aCollectorto consume streams of list tags.static @NotNull Collector<BinaryTag,?, ListBinaryTag> toListTag(@Nullable ListBinaryTag initial) Create aCollectorto consume streams of map entries, with initial contents.default @NotNull BinaryTagType<ListBinaryTag>type()Gets the tag type.@NotNull ListBinaryTagUnwrap any compound-boxed heterogeneous values in this tag.@NotNull ListBinaryTagWrap any heterogeneous values in this tag into compound-tag boxes.Methods inherited from interface net.kyori.adventure.nbt.BinaryTag
asBinaryTagMethods inherited from interface net.kyori.examination.Examinable
examinableName, examinableProperties, examineMethods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface net.kyori.adventure.nbt.ListTagSetter
add, add
-
Method Details
-
empty
Gets an empty list tag.- Returns:
- an empty tag
- Since:
- 4.0.0
-
from
Creates a list tag fromtags.The
element typeof the returned list tag is determined fromtags.- Parameters:
tags- the list of contents for the created tag- Returns:
- a list tag
- Throws:
IllegalArgumentException- iftagshas different tag types within- Since:
- 4.4.0
-
builder
Creates a builder.- Returns:
- a new builder
- Since:
- 4.0.0
-
heterogeneousListBinaryTag
Creates a builder that can accept elements of multiple types.- Returns:
- a new builder
- Since:
- 4.21.0
-
builder
@NotNull static <T extends BinaryTag> @NotNull ListBinaryTag.Builder<T> builder(@NotNull @NotNull BinaryTagType<T> type) Creates a builder.- Type Parameters:
T- the element type- Parameters:
type- the element type- Returns:
- a new builder
- Throws:
IllegalArgumentException- iftypeisBinaryTagTypes.END- Since:
- 4.0.0
-
listBinaryTag
@NotNull static @NotNull ListBinaryTag listBinaryTag(@NotNull @NotNull BinaryTagType<? extends BinaryTag> type, @NotNull @NotNull List<BinaryTag> tags) Creates a tag.If
tagsis empty,empty()will be returned.- Parameters:
type- the element typetags- the elements- Returns:
- a tag
- Throws:
IllegalArgumentException- iftypeisBinaryTagTypes.END, or if elements are of different types- Since:
- 4.14.0
-
of
@Deprecated @ScheduledForRemoval(inVersion="5.0.0") @NotNull static @NotNull ListBinaryTag of(@NotNull @NotNull BinaryTagType<? extends BinaryTag> type, @NotNull @NotNull List<BinaryTag> tags) Deprecated.for removal since 4.14.0, uselistBinaryTag(BinaryTagType, List)instead.Creates a tag.If
tagsis empty,empty()will be returned.- Parameters:
type- the element typetags- the elements- Returns:
- a tag
- Throws:
IllegalArgumentException- iftypeisBinaryTagTypes.END- Since:
- 4.0.0
-
toListTag
Create aCollectorto consume streams of list tags.- Returns:
- a collector of tags
- Since:
- 4.21.0
-
toListTag
@NotNull static @NotNull Collector<BinaryTag,?, toListTagListBinaryTag> (@Nullable @Nullable ListBinaryTag initial) Create aCollectorto 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
Description copied from interface:BinaryTagGets the tag type. -
listType
Deprecated.since 4.4.0, useelementType()insteadGets the type of element stored in this list.- Returns:
- the type
- Since:
- 4.0.0
-
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
@NotNull @NotNull 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
@NotNull @NotNull ListBinaryTag set(int index, @NotNull @NotNull BinaryTag tag, @Nullable @Nullable Consumer<? super BinaryTag> removed) Sets the tag at indexindextotag, optionally providingremovedConsumerwith the tag previously at indexindex.- Parameters:
index- the indextag- the tagremoved- a consumer which receives the tag being removed at indexindex- Returns:
- a list tag
- Since:
- 4.0.0
-
remove
@NotNull @NotNull ListBinaryTag remove(int index, @Nullable @Nullable Consumer<? super BinaryTag> removed) Removes the tag at indexindex, optionally providingremovedConsumerwith the tag previously at indexindex.- Parameters:
index- the indexremoved- a consumer which receives the tag being removed at indexindex- 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 indexdefaultValue- 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 indexdefaultValue- 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 indexdefaultValue- 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 indexdefaultValue- 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 indexdefaultValue- 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 indexdefaultValue- the default value- Returns:
- the double value, or
defaultValue - Since:
- 4.0.0
-
getByteArray
default byte @NotNull [] 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
default byte @NotNull [] getByteArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, byte @NotNull [] defaultValue) Gets an array of bytes.- Parameters:
index- the indexdefaultValue- the default value- Returns:
- the array of bytes, or
defaultValue - Since:
- 4.0.0
-
getString
@NotNull default @NotNull 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
@NotNull default @NotNull String getString(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @NotNull @NotNull String defaultValue) Gets a string.- Parameters:
index- the indexdefaultValue- the default value- Returns:
- the string value, or
defaultValue - Since:
- 4.0.0
-
getList
@NotNull default @NotNull 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
indexis not a list tag - Since:
- 4.4.0
-
getList
@NotNull default @NotNull ListBinaryTag getList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @Nullable @Nullable BinaryTagType<?> elementType) Gets a list.- Parameters:
index- the indexelementType- the expected element type of the list at indexindex- Returns:
- the list, or an empty list if the tag at index
indexis not a list tag, or if the list tag's element type is notelementType - Since:
- 4.4.0
-
getList
@NotNull default @NotNull ListBinaryTag getList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @NotNull @NotNull ListBinaryTag defaultValue) Gets a list.- Parameters:
index- the indexdefaultValue- the default value- Returns:
- the list, or
defaultValueif the tag at indexindexis not a list tag - Since:
- 4.4.0
-
getList
@NotNull default @NotNull ListBinaryTag getList(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @Nullable @Nullable BinaryTagType<?> elementType, @NotNull @NotNull ListBinaryTag defaultValue) Gets a list.If
elementTypeis non-nulland theListBinaryTagat indexindexdoes not match,defaultValuewill be returned.- Parameters:
index- the indexelementType- the expected element type of the list at indexindexdefaultValue- the default value- Returns:
- the list, or
defaultValueif the tag at indexindexis not a list tag, or if the list tag's element type is notelementType - Since:
- 4.4.0
-
getCompound
@NotNull default @NotNull 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
@NotNull default @NotNull CompoundBinaryTag getCompound(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, @NotNull @NotNull CompoundBinaryTag defaultValue) Gets a compound.- Parameters:
index- the indexdefaultValue- the default value- Returns:
- the compound, or
defaultValue - Since:
- 4.0.0
-
getIntArray
default int @NotNull [] 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
default int @NotNull [] getIntArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, int @NotNull [] defaultValue) Gets an array of ints.- Parameters:
index- the indexdefaultValue- the default value- Returns:
- the array of ints, or
defaultValue - Since:
- 4.0.0
-
getLongArray
default long @NotNull [] 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
default long @NotNull [] getLongArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int index, long @NotNull [] defaultValue) Gets an array of longs.- Parameters:
index- the indexdefaultValue- the default value- Returns:
- the array of longs, or
defaultValue - Since:
- 4.0.0
-
stream
Creates a stream of the tags contained within this list.- Returns:
- a new stream
- Since:
- 4.2.0
-
unwrapHeterogeneity
Unwrap any compound-boxed heterogeneous values in this tag.- Returns:
- a list tag that permits heterogeneity
- Since:
- 4.21.0
-
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
-
elementType()instead