T - The type of single value this will holdM - The type of DataManipulatorI - The type of ImmutableDataManipulatorpublic abstract class AbstractSingleData<T,M extends DataManipulator<M,I>,I extends ImmutableDataManipulator<I,M>> extends AbstractData<M,I>
DataManipulators that handle a single
value, adding the provided getValue() and setValue(Object)
methods for easy manipulation. This as well simplifies handling various
other common implementations, such as hashCode() and
equals(Object).| Modifier and Type | Field and Description |
|---|---|
protected T |
defaultValue |
protected Key<? extends BaseValue<T>> |
usedKey |
protected T |
value |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractSingleData(Key<? extends Value<T>> usedKey,
T value) |
protected |
AbstractSingleData(Key<? extends Value<T>> usedKey,
T value,
T defaultValue) |
protected |
AbstractSingleData(T value,
Key<? extends BaseValue<T>> usedKey)
Deprecated.
Use
AbstractSingleData(Key, Object) instead. |
| Modifier and Type | Method and Description |
|---|---|
abstract I |
asImmutable()
Gets an
ImmutableDataManipulator copy of this
DataManipulator such that all backed Values are copied
into ImmutableValue counterparts. |
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)
|
protected T |
getValue()
A simple getter for usage with a
Supplier for
the AbstractData.registerFieldGetter(Key, Supplier) method. |
protected abstract Value<?> |
getValueGetter()
Gets the
Value as a method since this manipulator only focuses
on a single value. |
int |
hashCode() |
protected void |
registerGettersAndSetters()
A required registration method for registering the various fields and
value getters.
|
protected M |
setValue(T value)
A simple setter for usage with a
Consumer for
the AbstractData.registerFieldSetter(Key, Consumer) method. |
boolean |
supports(Key<?> key)
Checks if the given
Key is supported by this
ValueContainer. |
getKeys, getValue, getValues, registerFieldGetter, registerFieldSetter, registerKeyValue, set, toContainer, transformclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitcopy, fill, fill, from, set, set, setgetContentVersiongetOrElse, getOrNull, require, supports@Deprecated protected AbstractSingleData(T value, Key<? extends BaseValue<T>> usedKey)
AbstractSingleData(Key, Object) instead.protected final void registerGettersAndSetters()
AbstractDataValue such that there is an
associated Key to "get" that field value.registerGettersAndSetters in class AbstractData<M extends DataManipulator<M,I>,I extends ImmutableDataManipulator<I,M>>protected abstract Value<?> getValueGetter()
Value as a method since this manipulator only focuses
on a single value.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<M extends DataManipulator<M,I>>get in class AbstractData<M extends DataManipulator<M,I>,I extends ImmutableDataManipulator<I,M>>E - The type of valuekey - The key linking thepublic boolean supports(Key<?> key)
ValueContainerKey is supported by this
ValueContainer.supports in interface ValueContainer<M extends DataManipulator<M,I>>supports in class AbstractData<M extends DataManipulator<M,I>,I extends ImmutableDataManipulator<I,M>>key - The key to checkpublic abstract I asImmutable()
DataManipulatorImmutableDataManipulator copy of this
DataManipulator such that all backed Values are copied
into ImmutableValue counterparts. Any changes to this
DataManipulator will NOT be reflected on the returned
ImmutableDataManipulator and vice versa.DataManipulator's data copied into a
ImmutableDataManipulatorprotected T getValue()
Supplier for
the AbstractData.registerFieldGetter(Key, Supplier) method.protected M setValue(T value)
Consumer for
the AbstractData.registerFieldSetter(Key, Consumer) method.value - The valueprotected DataContainer fillContainer(DataContainer dataContainer)
AbstractDatafillContainer in class AbstractData<M extends DataManipulator<M,I>,I extends ImmutableDataManipulator<I,M>>dataContainer - The data containerpublic int hashCode()
hashCode in class AbstractData<M extends DataManipulator<M,I>,I extends ImmutableDataManipulator<I,M>>public boolean equals(Object obj)
equals in class AbstractData<M extends DataManipulator<M,I>,I extends ImmutableDataManipulator<I,M>>