public interface PersistentDataContainer
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
get(java.lang.String key)
Get a metadata value matching the provided key.
|
<T> T |
get(java.lang.String key,
PersistentDataType<T> type)
Get a metadata value matching the provided key and type.
|
java.lang.Object |
getOrDefault(java.lang.String key,
java.lang.Object def)
Get a metadata value matching the provided key.
|
<T> T |
getOrDefault(java.lang.String key,
PersistentDataType<T> type,
T def)
Get a metadata value matching the provided key and type.
|
boolean |
has(java.lang.String key)
Check if the provided key has a matching metadata value.
|
<T> boolean |
hasKeyOfType(java.lang.String key,
PersistentDataType<T> type)
Check if the provided key has a matching metadata value of the provided type.
|
boolean |
isEmpty()
Check whether the container is empty.
|
void |
load(byte[] data)
Load contents from the serialized data into the container.
|
<T> T |
put(java.lang.String key,
PersistentDataType<T> type,
T value)
Store a metadata value matching the provided key and type.
|
<T,R> R |
put(java.lang.String key,
PersistentDataType<T> type,
T value,
PersistentDataType<R> returnType)
Store a metadata value matching the provided key and type.
|
java.lang.Object |
remove(java.lang.String key)
Remove a metadata value matching the provided key.
|
<T> T |
removeKeyOfType(java.lang.String key,
PersistentDataType<T> type)
Remove a metadata value matching the provided key and type.
|
byte[] |
serialize()
Get the serialized contents of the container as a bytes array.
|
int |
size()
Get the size of the container.
|
boolean has(java.lang.String key)
key
- The key to check.<T> boolean hasKeyOfType(java.lang.String key, PersistentDataType<T> type)
key
- The key to check.type
- The type to check.@Nullable <T> T put(java.lang.String key, PersistentDataType<T> type, T value) throws org.apache.commons.lang.IllegalClassException, java.lang.IllegalStateException
key
- The key to store.type
- The type of the metadata value.value
- The metadata value to store.org.apache.commons.lang.IllegalClassException
- If the old metadata value is not of type .java.lang.IllegalStateException
- If doesn't have a valid serializer available.@Nullable <T,R> R put(java.lang.String key, PersistentDataType<T> type, T value, PersistentDataType<R> returnType) throws org.apache.commons.lang.IllegalClassException, java.lang.IllegalStateException
key
- The key to store.type
- The type of the metadata.value
- The metadata value to store.returnType
- The type of the old metadata value.org.apache.commons.lang.IllegalClassException
- If the old metadata value is not of type .java.lang.IllegalStateException
- If doesn't have a valid serializer available.@Nullable java.lang.Object remove(java.lang.String key)
key
- The key to remove.@Nullable <T> T removeKeyOfType(java.lang.String key, PersistentDataType<T> type)
key
- The key to remove.type
- The type of the metadata value to remove.@Nullable <T> T get(java.lang.String key, PersistentDataType<T> type) throws org.apache.commons.lang.IllegalClassException
key
- The key to fetch.type
- The type of the metadata value to fetch.org.apache.commons.lang.IllegalClassException
- If the metadata value is not of type .@Nullable java.lang.Object get(java.lang.String key)
key
- The key to fetch.<T> T getOrDefault(java.lang.String key, PersistentDataType<T> type, T def) throws org.apache.commons.lang.IllegalClassException
key
- The key to fetch.type
- The type of the metadata value to fetch.def
- Value to return in case there is no metadata value matching the provided key.org.apache.commons.lang.IllegalClassException
- If the metadata value is not of type .java.lang.Object getOrDefault(java.lang.String key, java.lang.Object def)
key
- The key to fetch.def
- Value to return in case there is no metadata value matching the provided key.boolean isEmpty()
int size()
byte[] serialize()
load(byte[])
.void load(byte[] data) throws java.lang.IllegalArgumentException
data
- The serialized data.java.lang.IllegalArgumentException
- If the given data cannot be serialized correctly.