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.

    @FunctionalInterface
    public interface MergeFunction
    Represents a unique form of Function that attempts to merge two separate Values into a singular Value. A merge function is similar to a Function such that it can be reused for multiple purposes and should be "stateless" on its own.
    • Field Detail

      • REPLACEMENT_PREFERRED

        static final MergeFunction REPLACEMENT_PREFERRED
        Represents a MergeFunction that ignores all merges and uses the replacement, or the original if the replacement is null.
      • ORIGINAL_PREFERRED

        static final MergeFunction ORIGINAL_PREFERRED
        Represents a MergeFunction that will preferr the original's value if it is not null over the replacement.
    • Method Detail

      • merge

        <V extends Value<E>,​E> V merge​(@Nullable V original,
                                             @Nullable V replacement)
        Performs a merge of a type of Value such that a merge has been performed and the resulting merged Value is returned. It is suffice to say that only one of the Values may be null, such that
         
         if (original == null) {
             return checkNotNull(replacement);
         } else if (replacement == null) {
             return original;
         } else {
             // do something merging the necessary values
         }
         
        It can be therefor discerned that both values are passed in as copies and therefor either one can be modified and returned.
        Type Parameters:
        V - The type of Value being passed in
        E - The type of value for the Value
        Parameters:
        original - The original Value from the value store
        replacement - The replacing value container
        Returns:
        The "merged" Value