I - The immutable data manipulator typeM - The mutable manipulator typepublic abstract class AbstractImmutableData<I extends ImmutableDataManipulator<I,M>,M extends DataManipulator<M,I>> extends Object implements ImmutableDataManipulator<I,M>
ImmutableDataManipulator such that
all fields are declared final and remain "immutable".| Modifier | Constructor and Description |
|---|---|
protected |
AbstractImmutableData() |
| Modifier and Type | Method and Description |
|---|---|
I |
copy()
Creates a clone copy of this
ValueContainer as a new
ValueContainer such that all the BaseValues are
safely duplicated to the new instance. |
boolean |
equals(Object obj) |
protected DataContainer |
fillContainer(DataContainer dataContainer)
Implement this method to add the data to be persisted.
|
<E> Optional<E> |
get(Key<? extends BaseValue<E>> key)
|
Set<Key<?>> |
getKeys()
Gets all applicable
Keys for this ValueContainer. |
<E,V extends BaseValue<E>> |
getValue(Key<V> key)
|
Set<ImmutableValue<?>> |
getValues()
Gets all applicable
BaseValues associated with this
ValueContainer. |
int |
hashCode() |
protected void |
registerFieldGetter(Key<?> key,
Supplier<?> function)
Simple registration method for the keys to field getter methods.
|
protected abstract void |
registerGetters() |
protected void |
registerKeyValue(Key<?> key,
Supplier<ImmutableValue<?>> function)
Simple registration method for the keys to value return methods.
|
boolean |
supports(Key<?> key)
Checks if the given
Key is supported by this
ValueContainer. |
DataContainer |
toContainer()
Serializes this object into a comprehensible
DataContainer. |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitasMutable, with, withgetContentVersiongetOrElse, getOrNull, require, supportsprotected final void registerKeyValue(Key<?> key, Supplier<ImmutableValue<?>> function)
Note that this is still usable with Java 8 method references.
Referencing this::getfoo() is recommended.
key - The key for the value return typefunction - The function for getting the valueprotected final void registerFieldGetter(Key<?> key, Supplier<?> function)
Note that this is still usable with Java 8 method references.
Referencing this::getfoo() is recommended.
key - The key for the value return typefunction - The function for getting the fieldprotected abstract void registerGetters()
public final I copy()
ValueContainerValueContainer as a new
ValueContainer such that all the BaseValues are
safely duplicated to the new instance.copy in interface ImmutableDataManipulator<I extends ImmutableDataManipulator<I,M>,M extends DataManipulator<M,I>>copy in interface ValueContainer<I extends ImmutableDataManipulator<I,M>>public <E> Optional<E> get(Key<? extends BaseValue<E>> key)
ValueContainerBaseValue
linked to the provided Key. If the Key is not
supported, Optional.empty() is returned. It is important
to check for support of a Key by either calling
ValueContainer.supports(BaseValue) or ValueContainer.supports(Key).get in interface ValueContainer<I extends ImmutableDataManipulator<I,M>>E - The type of valuekey - The key linking thepublic <E,V extends BaseValue<E>> Optional<V> getValue(Key<V> key)
ValueContainergetValue in interface ValueContainer<I extends ImmutableDataManipulator<I,M>>E - The type of the return typeV - The type of valuekey - The key linked to the BaseValuepublic boolean supports(Key<?> key)
ValueContainerKey is supported by this
ValueContainer.supports in interface ValueContainer<I extends ImmutableDataManipulator<I,M>>key - The key to checkpublic Set<Key<?>> getKeys()
ValueContainerKeys for this ValueContainer.
Changes can not be made to the set to alter the ValueContainer,
nor can the BaseValues be changed with the provided
ImmutableSet.getKeys in interface ValueContainer<I extends ImmutableDataManipulator<I,M>>Keyspublic Set<ImmutableValue<?>> getValues()
ValueContainerBaseValues associated with this
ValueContainer. As the data backed by the values are copied,
any modifications to the BaseValues will not be reflected onto
this ValueContainer.getValues in interface ValueContainer<I extends ImmutableDataManipulator<I,M>>public DataContainer toContainer()
DataSerializableDataContainer.toContainer in interface DataSerializableprotected DataContainer fillContainer(DataContainer dataContainer)
dataContainer - The data container