Class SetDiff<E>

  • Type Parameters:
    E - the type of elements in this diff
    All Implemented Interfaces:
    IDiff

    public abstract class SetDiff<E>
    extends Object
    implements IDiff
    Describes the difference between two sets
    Since:
    1.0
    • Constructor Detail

      • SetDiff

        public SetDiff()
    • Method Detail

      • getAdditions

        public abstract Set<E> getAdditions()
        Returns:
        the set of added elements
      • getRemovals

        public abstract Set<E> getRemovals()
        Returns:
        the set of removed elements
      • isEmpty

        public boolean isEmpty()
        Returns true if the diff has no added or removed elements.
        Returns:
        true if the diff has no added or removed elements.
        Since:
        1.2
      • applyTo

        public void applyTo​(Set<? super E> set)
        Applies the changes in this diff to the given set
        Parameters:
        set - the set to which the diff will be applied
        Since:
        1.2
      • simulateOn

        public Set<E> simulateOn​(Set<E> set)
        Returns a Set showing what set would look like if this diff were applied to it. The passed-in list is presumed to contain all elements in getRemovals(), and none of the elements in getAdditions().

        Note:the returned list is only guaranteed to be valid while the passed in set remains unchanged.

        Parameters:
        set - the set over which the diff will be simulated
        Returns:
        a Set showing what set would look like if it were passed to the applyTo(Set) method.
        Since:
        1.3