Class MetadataHolder
java.lang.Object
net.mathias2246.buildmc.util.MetadataHolder
- Direct Known Subclasses:
Team
Base class providing metadata storage.
Metadata allows additional context to be stored and shared with plugins. Each entry is a key-value pair. Keys must be unique within a metadata holder instance.
This class provides an unmodifiable view for external access to prevent accidental modification of the internal state.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsMetadataKey(@NotNull String key) Checks if a certain metadata key is present in this instance.Returns an unmodifiable view of all metadata entries stored in this instance.Provides internal access to the mutable metadata map.voidputMetadata(@NotNull String key, @NotNull Object value) Adds a new metadata entry or updates the value for an existing key.voidremoveMetadata(@NotNull String key) Removes a metadata entry from this instance.
-
Constructor Details
-
MetadataHolder
public MetadataHolder()
-
-
Method Details
-
getMetadata
Returns an unmodifiable view of all metadata entries stored in this instance.This map should not be modified directly; use
putMetadata(String, Object)orremoveMetadata(String)to update entries.- Returns:
- an unmodifiable map containing all metadata (never
null)
-
mutableMetadata
-
containsMetadataKey
Checks if a certain metadata key is present in this instance.- Parameters:
key- The key to check- Returns:
trueif the given metadata key is present in this instance.
-
putMetadata
Adds a new metadata entry or updates the value for an existing key.- Parameters:
key- the metadata key (must not benull)value- the metadata value (must not benull)- Throws:
NullPointerException- ifkeyorvalueisnull
-
removeMetadata
Removes a metadata entry from this instance.If the key does not exist, this method does nothing.
- Parameters:
key- the metadata key to remove (must not benull)- Throws:
NullPointerException- ifkeyisnull
-