Package org.spongepowered.api.data.value
Interface MergeFunction
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final MergeFunction
Represents aMergeFunction
that will preferr the original's value if it is notnull
over the replacement.static final MergeFunction
Represents aMergeFunction
that ignores all merges and uses the replacement, or the original if the replacement isnull
. -
Method Summary
Modifier and TypeMethodDescriptiondefault MergeFunction
andThen
(MergeFunction that) Creates a newMergeFunction
chaining this current merge function with the provided merge function.<V extends Value<E>,
E>
Vmerge
(@Nullable V original, @Nullable V replacement)
-
Field Details
-
REPLACEMENT_PREFERRED
Represents aMergeFunction
that ignores all merges and uses the replacement, or the original if the replacement isnull
. -
ORIGINAL_PREFERRED
Represents aMergeFunction
that will preferr the original's value if it is notnull
over the replacement.
-
-
Method Details
-
merge
Performs a merge of a type ofValue
such that a merge has been performed and the resulting mergedValue
is returned. It is suffice to say that only one of theValue
s may benull
, such thatif (original == null) { return checkNotNull(replacement); } else if (replacement == null) { return original; } else { // do something merging the necessary values }
-
andThen
Creates a newMergeFunction
chaining this current merge function with the provided merge function. The order of the merge is this performsmerge(Value, Value)
then, the providedMergeFunction
merges the returned mergedValueContainer
and thereplacement
. This can be used to apply a custom merge strategy after a pre-definedMergeFunction
is applied.- Parameters:
that
- TheMergeFunction
to chain- Returns:
- The new
MergeFunction
-