Package net.kyori.adventure.nbt
Interface CompoundBinaryTag
- All Superinterfaces:
BinaryTag,BinaryTagLike,CompoundTagSetter<CompoundBinaryTag>,net.kyori.examination.Examinable,Iterable<Map.Entry<String,? extends BinaryTag>>
public interface CompoundBinaryTag
extends BinaryTag, CompoundTagSetter<CompoundBinaryTag>, Iterable<Map.Entry<String,? extends BinaryTag>>
Binary tag holding a mapping of string keys to
BinaryTag values.- Since:
- 4.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA compound tag builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull CompoundBinaryTag.Builderbuilder()Creates a builder.static @NotNull CompoundBinaryTagempty()Gets an empty compound tag.static @NotNull CompoundBinaryTagCreates a compound tag populated withtags.@Nullable BinaryTagGets a tag.default booleangetBoolean(@NotNull String key) Gets a boolean.default booleangetBoolean(@NotNull String key, boolean defaultValue) Gets a boolean.default byteGets a byte.byteGets a byte.byte @NotNull []getByteArray(@NotNull String key) Gets an array of bytes.byte @NotNull []getByteArray(@NotNull String key, byte @NotNull [] defaultValue) Gets an array of bytes.default @NotNull CompoundBinaryTaggetCompound(@NotNull String key) Gets a compound.@NotNull CompoundBinaryTaggetCompound(@NotNull String key, @NotNull CompoundBinaryTag defaultValue) Gets a compound.default doubleGets a double.doubleGets a double.default floatGets a float.floatGets a float.default intGets an int.intGets an int.int @NotNull []getIntArray(@NotNull String key) Gets an array of ints.int @NotNull []getIntArray(@NotNull String key, int @NotNull [] defaultValue) Gets an array of ints.default @NotNull ListBinaryTagGets a list.default @NotNull ListBinaryTaggetList(@NotNull String key, @NotNull BinaryTagType<? extends BinaryTag> expectedType) Gets a list, ensuring that the type is the same astype.@NotNull ListBinaryTaggetList(@NotNull String key, @NotNull BinaryTagType<? extends BinaryTag> expectedType, @NotNull ListBinaryTag defaultValue) Gets a list, ensuring that the type is the same astype.@NotNull ListBinaryTaggetList(@NotNull String key, @NotNull ListBinaryTag defaultValue) Gets a list.default longGets a long.longGets a long.long @NotNull []getLongArray(@NotNull String key) Gets an array of longs.long @NotNull []getLongArray(@NotNull String key, long @NotNull [] defaultValue) Gets an array of longs.default shortGets a short.shortGets a short.default @NotNull StringGets a string.@NotNull StringGets a string.booleanisEmpty()Returns whether the compound has tags or not.keySet()Gets a set of all keys.intsize()Gets the number of elements in the compound.stream()Gets a stream of entries in this compound tag.static @NotNull Collector<Map.Entry<String,? extends BinaryTag>, ?, CompoundBinaryTag> Create aCollectorto consume streams of map entries.static <T> @NotNull Collector<T,?, CompoundBinaryTag> toCompoundTag(@NotNull Function<T, String> keyLens, @NotNull Function<T, ? extends BinaryTag> valueLens) Create aCollectorto consume streams of a user-chosen type.static @NotNull Collector<Map.Entry<String,? extends BinaryTag>, ?, CompoundBinaryTag> toCompoundTag(@NotNull CompoundBinaryTag initial) Create aCollectorto consume streams of map entries, with initial contents.static <T> @NotNull Collector<T,?, CompoundBinaryTag> toCompoundTag(@NotNull CompoundBinaryTag initial, @NotNull Function<T, String> keyLens, @NotNull Function<T, ? extends BinaryTag> valueLens) Create aCollectorto consume streams of a user-chosen type, with initial contents.default @NotNull BinaryTagType<CompoundBinaryTag>type()Gets the tag type.Methods inherited from interface net.kyori.adventure.nbt.BinaryTag
asBinaryTagMethods inherited from interface net.kyori.adventure.nbt.CompoundTagSetter
put, put, put, putBoolean, putByte, putByteArray, putDouble, putFloat, putInt, putIntArray, putLong, putLongArray, putShort, putString, remove, removeMethods inherited from interface net.kyori.examination.Examinable
examinableName, examinableProperties, examineMethods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
empty
Gets an empty compound tag.- Returns:
- an empty tag
- Since:
- 4.0.0
-
from
@NotNull static @NotNull CompoundBinaryTag from(@NotNull @NotNull Map<String, ? extends BinaryTag> tags) Creates a compound tag populated withtags.If
tagsis empty,empty()will be returned.- Parameters:
tags- the map of contents for the created tag- Returns:
- a compound tag
- Since:
- 4.4.0
-
toCompoundTag
@NotNull static @NotNull Collector<Map.Entry<String,? extends BinaryTag>, toCompoundTag()?, CompoundBinaryTag> Create aCollectorto consume streams of map entries.In the event of duplicate entries, the last seen entry will be preserved.
- Returns:
- a collector for map entries
- Since:
- 4.21.0
-
toCompoundTag
@NotNull static <T> @NotNull Collector<T,?, toCompoundTagCompoundBinaryTag> (@NotNull @NotNull Function<T, String> keyLens, @NotNull @NotNull Function<T, ? extends BinaryTag> valueLens) Create aCollectorto consume streams of a user-chosen type.In the event of duplicate keys, the last seen entry will be preserved.
- Type Parameters:
T- the stream value type- Parameters:
keyLens- a function to extract a key from the target objectvalueLens- a function to extract a tag value from the target object- Returns:
- a collector creating compound tags
- Since:
- 4.21.0
-
toCompoundTag
@NotNull static @NotNull Collector<Map.Entry<String,? extends BinaryTag>, toCompoundTag?, CompoundBinaryTag> (@NotNull @NotNull CompoundBinaryTag 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
-
toCompoundTag
@NotNull static <T> @NotNull Collector<T,?, toCompoundTagCompoundBinaryTag> (@NotNull @NotNull CompoundBinaryTag initial, @NotNull @NotNull Function<T, String> keyLens, @NotNull @NotNull Function<T, ? extends BinaryTag> valueLens) Create aCollectorto consume streams of a user-chosen type, with initial contents.In the event of duplicate keys, the last seen entry will be preserved.
- Type Parameters:
T- the stream value type- Parameters:
initial- an existing tag that will initialize the builderkeyLens- a function to extract a key from the target objectvalueLens- a function to extract a tag value from the target object- Returns:
- a collector creating compound tags
- Since:
- 4.21.0
-
builder
Creates a builder.- Returns:
- a new builder
- Since:
- 4.0.0
-
type
Description copied from interface:BinaryTagGets the tag type. -
keySet
Gets a set of all keys.- Returns:
- the keys
- Since:
- 4.0.0
-
get
Gets a tag.- Parameters:
key- the key- Returns:
- a tag
- Since:
- 4.0.0
-
size
int size()Gets the number of elements in the compound.- Returns:
- the number of elements in the compound
- Since:
- 4.15.0
-
isEmpty
boolean isEmpty()Returns whether the compound has tags or not.- Returns:
- false if the compound has tags
- Since:
- 4.18.0
-
getBoolean
Gets a boolean.Booleans are stored as a
ByteBinaryTagwith a value of0forfalseand1fortrue.- Parameters:
key- the key- Returns:
- the boolean value, or
falseif this compound does not contain a boolean tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getBoolean
Gets a boolean.Booleans are stored as a
ByteBinaryTagwith a value of0forfalseand1fortrue.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the boolean value, or
defaultValueif this compound does not contain a boolean tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getByte
Gets a byte.- Parameters:
key- the key- Returns:
- the byte value, or
0if this compound does not contain a byte tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getByte
Gets a byte.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the byte value, or
defaultValueif this compound does not contain a byte tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getShort
Gets a short.- Parameters:
key- the key- Returns:
- the short value, or
0if this compound does not contain a short tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getShort
Gets a short.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the short value, or
defaultValueif this compound does not contain a short tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getInt
Gets an int.- Parameters:
key- the key- Returns:
- the int value, or
0if this compound does not contain an int tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getInt
Gets an int.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the int value, or
defaultValueif this compound does not contain an int tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getLong
Gets a long.- Parameters:
key- the key- Returns:
- the long value, or
0if this compound does not contain a long tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getLong
Gets a long.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the long value, or
defaultValueif this compound does not contain a long tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getFloat
Gets a float.- Parameters:
key- the key- Returns:
- the float value, or
0if this compound does not contain a float tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getFloat
Gets a float.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the float value, or
defaultValueif this compound does not contain a float tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getDouble
Gets a double.- Parameters:
key- the key- Returns:
- the double value, or
0if this compound does not contain a double tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getDouble
Gets a double.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the double value, or
defaultValueif this compound does not contain a double tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getByteArray
Gets an array of bytes.- Parameters:
key- the key- Returns:
- the array of bytes, or a zero-length array if this compound does not contain a byte array tag with the specified key, or has a tag with a different type
- Since:
- 4.0.0
-
getByteArray
Gets an array of bytes.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the array of bytes, or
defaultValue - Since:
- 4.0.0
-
getString
Gets a string.- Parameters:
key- the key- Returns:
- the string value, or
""if this compound does not contain a string tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getString
@NotNull @NotNull String getString(@NotNull @NotNull String key, @NotNull @NotNull String defaultValue) Gets a string.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the string value, or
defaultValueif this compound does not contain a string tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getList
Gets a list.- Parameters:
key- the key- Returns:
- the list, or a new list if this compound does not contain a list tag with the specified key, or has a tag with a different type
- Since:
- 4.0.0
-
getList
@NotNull @NotNull ListBinaryTag getList(@NotNull @NotNull String key, @NotNull @NotNull ListBinaryTag defaultValue) Gets a list.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the list, or
defaultValueif this compound does not contain a list tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getList
@NotNull default @NotNull ListBinaryTag getList(@NotNull @NotNull String key, @NotNull @NotNull BinaryTagType<? extends BinaryTag> expectedType) Gets a list, ensuring that the type is the same astype.- Parameters:
key- the keyexpectedType- the expected list type- Returns:
- the list, or a new list if this compound does not contain a list tag
with the specified key, has a tag with a different type, or the
list typedoes not matchexpectedType - Since:
- 4.0.0
-
getList
@NotNull @NotNull ListBinaryTag getList(@NotNull @NotNull String key, @NotNull @NotNull BinaryTagType<? extends BinaryTag> expectedType, @NotNull @NotNull ListBinaryTag defaultValue) Gets a list, ensuring that the type is the same astype.- Parameters:
key- the keyexpectedType- the expected list typedefaultValue- the default value- Returns:
- the list, or
defaultValueif this compound does not contain a list tag with the specified key, has a tag with a different type, or thelist typedoes not matchexpectedType - Since:
- 4.0.0
-
getCompound
Gets a compound.- Parameters:
key- the key- Returns:
- the compound, or a new compound if this compound does not contain a compound tag with the specified key, or has a tag with a different type
- Since:
- 4.0.0
-
getCompound
@NotNull @NotNull CompoundBinaryTag getCompound(@NotNull @NotNull String key, @NotNull @NotNull CompoundBinaryTag defaultValue) Gets a compound.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the compound, or
defaultValueif this compound does not contain a compound tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getIntArray
Gets an array of ints.- Parameters:
key- the key- Returns:
- the array of ints, or a zero-length array if this compound does not contain a int array tag with the specified key, or has a tag with a different type
- Since:
- 4.0.0
-
getIntArray
Gets an array of ints.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the array of ints, or
defaultValue - Since:
- 4.0.0
-
getLongArray
Gets an array of longs.- Parameters:
key- the key- Returns:
- the array of longs, or a zero-length array if this compound does not contain a long array tag with the specified key, or has a tag with a different type
- Since:
- 4.0.0
-
getLongArray
Gets an array of longs.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the array of longs, or
defaultValue - Since:
- 4.0.0
-
stream
Gets a stream of entries in this compound tag.- Returns:
- a new entry stream
- Since:
- 4.21.0
-