public final class DataProcessorDelegate<M extends org.spongepowered.api.data.manipulator.DataManipulator<M,I>,I extends org.spongepowered.api.data.manipulator.ImmutableDataManipulator<I,M>> extends Object implements DataProcessor<M,I>
Constructor and Description |
---|
DataProcessorDelegate(ImmutableList<DataProcessor<M,I>> processors) |
Modifier and Type | Method and Description |
---|---|
Optional<M> |
createFrom(org.spongepowered.api.data.DataHolder dataHolder) |
Optional<M> |
fill(org.spongepowered.api.data.DataContainer container,
M m) |
Optional<M> |
fill(org.spongepowered.api.data.DataHolder dataHolder,
M manipulator,
org.spongepowered.api.data.merge.MergeFunction overlap) |
Optional<M> |
from(org.spongepowered.api.data.DataHolder dataHolder)
Attempts to get the given
DataManipulator of type T if
and only if the manipulator's required data exists from the
DataHolder . |
int |
getPriority()
Gets the priority of this processor.
|
org.spongepowered.api.data.DataTransactionResult |
remove(org.spongepowered.api.data.DataHolder dataHolder)
Attempts to remove the
DataManipulator type from the given DataHolder . |
org.spongepowered.api.data.DataTransactionResult |
set(org.spongepowered.api.data.DataHolder dataHolder,
M manipulator,
org.spongepowered.api.data.merge.MergeFunction function)
Sets the data from the
DataManipulator . |
boolean |
supports(org.spongepowered.api.data.DataHolder dataHolder) |
boolean |
supports(org.spongepowered.api.entity.EntityType entityType) |
Optional<I> |
with(org.spongepowered.api.data.key.Key<? extends org.spongepowered.api.data.value.BaseValue<?>> key,
Object value,
I immutable) |
public DataProcessorDelegate(ImmutableList<DataProcessor<M,I>> processors)
public int getPriority()
DataProcessor
Key
can have
multiple DataProcessor
s such that mods introducing
changes to the game can provide their own DataProcessor
s
for specific cases. The notion is that the higher the priority, the
earlier the processor is used. If for any reason a processor's method
is returning an Optional.absent()
or
DataTransactionResult
with a failure, the next processor in
line will be used. By default, all Sponge processors are with a
priority of 100.getPriority
in interface DataProcessor<M extends org.spongepowered.api.data.manipulator.DataManipulator<M,I>,I extends org.spongepowered.api.data.manipulator.ImmutableDataManipulator<I,M>>
public boolean supports(org.spongepowered.api.data.DataHolder dataHolder)
public boolean supports(org.spongepowered.api.entity.EntityType entityType)
public Optional<M> from(org.spongepowered.api.data.DataHolder dataHolder)
DataProcessor
DataManipulator
of type T
if
and only if the manipulator's required data exists from the
DataHolder
. This is conceptually different from
DataProcessor.createFrom(DataHolder)
since a new instance
isn't returned even if the DataManipulator
is applicable.
This is a processor method for CompositeValueStore.get(Class)
.
public Optional<M> fill(org.spongepowered.api.data.DataHolder dataHolder, M manipulator, org.spongepowered.api.data.merge.MergeFunction overlap)
public org.spongepowered.api.data.DataTransactionResult set(org.spongepowered.api.data.DataHolder dataHolder, M manipulator, org.spongepowered.api.data.merge.MergeFunction function)
DataProcessor
DataManipulator
. Usually, if a
DataHolder
is being offered a DataManipulator
with a
MergeFunction
, the MergeFunction
logic should always
be settled first, before offering the finalized DataManipulator
to the DataHolder
. In the case of implementation, what really
happens is that all pre-logic before data is actually "offered" to a
DataHolder
, the data is filtered for various reasons from
various plugins. After the data is finished being manipulatoed
by the various sources, including the possibly provided
MergeFunction
, the DataManipulator
is finally offered
to the DataHolder
. The resulting DataTransactionResult
is almost always made ahead of time.set
in interface DataProcessor<M extends org.spongepowered.api.data.manipulator.DataManipulator<M,I>,I extends org.spongepowered.api.data.manipulator.ImmutableDataManipulator<I,M>>
dataHolder
- The data holder to set the data ontomanipulator
- The manipulator to set the data frompublic Optional<I> with(org.spongepowered.api.data.key.Key<? extends org.spongepowered.api.data.value.BaseValue<?>> key, Object value, I immutable)
public org.spongepowered.api.data.DataTransactionResult remove(org.spongepowered.api.data.DataHolder dataHolder)
DataProcessor
DataManipulator
type from the given DataHolder
.
If the DataHolder
can not support removing the data outright,
false
should be returned.
remove
in interface DataProcessor<M extends org.spongepowered.api.data.manipulator.DataManipulator<M,I>,I extends org.spongepowered.api.data.manipulator.ImmutableDataManipulator<I,M>>
dataHolder
- The data holder to remove the data frompublic Optional<M> createFrom(org.spongepowered.api.data.DataHolder dataHolder)
createFrom
in interface DataProcessor<M extends org.spongepowered.api.data.manipulator.DataManipulator<M,I>,I extends org.spongepowered.api.data.manipulator.ImmutableDataManipulator<I,M>>