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 SummaryFieldsModifier and TypeFieldDescriptionstatic final MergeFunctionRepresents aMergeFunctionthat will preferr the original's value if it is notnullover the replacement.static final MergeFunctionRepresents aMergeFunctionthat ignores all merges and uses the replacement, or the original if the replacement isnull.
- 
Method SummaryModifier and TypeMethodDescriptiondefault MergeFunctionandThen(MergeFunction that) Creates a newMergeFunctionchaining this current merge function with the provided merge function.<V extends Value<E>,E> 
 Vmerge(@Nullable V original, @Nullable V replacement) 
- 
Field Details- 
REPLACEMENT_PREFERREDRepresents aMergeFunctionthat ignores all merges and uses the replacement, or the original if the replacement isnull.
- 
ORIGINAL_PREFERREDRepresents aMergeFunctionthat will preferr the original's value if it is notnullover the replacement.
 
- 
- 
Method Details- 
mergePerforms a merge of a type ofValuesuch that a merge has been performed and the resulting mergedValueis returned. It is suffice to say that only one of theValues may benull, such that
 It can be therefor discerned that both values are passed in as copies and therefor either one can be modified and returned.if (original == null) { return checkNotNull(replacement); } else if (replacement == null) { return original; } else { // do something merging the necessary values }
- 
andThenCreates a newMergeFunctionchaining this current merge function with the provided merge function. The order of the merge is this performsmerge(Value, Value)then, the providedMergeFunctionmerges the returned mergedValueContainerand thereplacement. This can be used to apply a custom merge strategy after a pre-definedMergeFunctionis applied.- Parameters:
- that- The- MergeFunctionto chain
- Returns:
- The new MergeFunction
 
 
-