Class Tag<T>
java.lang.Object
de.pauleff.core.Tag<T>
- Type Parameters:
T- the data type stored within this tag
- All Implemented Interfaces:
ITag<T>
- Direct Known Subclasses:
Basic_Tag,Collection_Tag
Foundation class for all NBT tags, providing core functionality for data storage,
identification, and manipulation within the NBT hierarchy.
Each tag maintains a unique identifier, optional name, and typed data payload. Tags support fluent operations, equality checking, and custom transformations.
- Author:
- Paul Ferlitz
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyOperation(Consumer<ITag<T>> operation) Applies a custom transformation or operation to this tag.voidReplaces this tag's content with data from another compatible tag.booleanDetermines equality based on tag ID, name, and data content.getData()Returns the data payload stored within this tag.intgetId()Returns the NBT type identifier for this tag.getName()Returns the name assigned to this tag.inthashCode()voidUpdates the data payload with type validation.voidUpdates the name assigned to this tag.toString()Generates a human-readable representation showing tag type, name, and data.
-
Field Details
-
data
-
-
Constructor Details
-
Tag
public Tag(int id) Creates a new tag with the specified NBT type identifier.- Parameters:
id- the NBT type identifier- Throws:
IllegalArgumentException- if the ID is not a valid NBT tag type
-
Tag
Creates a new named tag with the specified NBT type identifier.- Parameters:
id- the NBT type identifiername- the tag name (null or empty becomes "null")- Throws:
IllegalArgumentException- if the ID is not a valid NBT tag type
-
Tag
Creates a new tag with complete initialization.- Parameters:
id- the NBT type identifiername- the tag name (null or empty becomes "null")data- the initial payload for this tag- Throws:
IllegalArgumentException- if the ID is not a valid NBT tag type
-
-
Method Details
-
getId
-
getName
-
setName
-
getData
-
setData
Updates the data payload with type validation.- Specified by:
setDatain interfaceITag<T>- Parameters:
data- the new data content- Throws:
IllegalArgumentException- if the data type doesn't match the existing type
-
editTag
Replaces this tag's content with data from another compatible tag.- Specified by:
editTagin interfaceITag<T>- Parameters:
newTag- the source tag to copy from- Throws:
IllegalArgumentException- if tag types don't match- See Also:
-
applyOperation
-
equals
-
hashCode
-
toString
-