Class SetDiff<E>

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

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

      Constructors 
      Constructor Description
      SetDiff()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void applyTo​(java.util.Set<? super E> set)
      Applies the changes in this diff to the given set
      abstract java.util.Set<E> getAdditions()  
      abstract java.util.Set<E> getRemovals()  
      boolean isEmpty()
      Returns true if the diff has no added or removed elements.
      java.util.Set<E> simulateOn​(java.util.Set<E> set)
      Returns a Set showing what set would look like if this diff were applied to it.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • SetDiff

        public SetDiff()
    • Method Detail

      • getAdditions

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

        public abstract java.util.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​(java.util.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 java.util.Set<E> simulateOn​(java.util.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
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object