Class ListDiff<E>

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

    public abstract class ListDiff<E>
    extends java.lang.Object
    implements IDiff
    Object describing a diff between two lists.
    Since:
    1.0
    • Constructor Summary

      Constructors 
      Constructor Description
      ListDiff()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void accept​(ListDiffVisitor<? super E> visitor)
      Traverses the getDifferences() array, calling the appropriate method in visitor for each difference.
      void applyTo​(java.util.List<? super E> list)
      Applies the changes in this diff to the given list
      abstract ListDiffEntry<E>[] getDifferences()
      Returns a ListDiffEntry array representing the differences in the list, in the order they are to be processed.
      boolean isEmpty()
      Returns true if the diff contains no added, removed, moved or replaced elements.
      java.util.List<E> simulateOn​(java.util.List<E> list)
      Returns a list showing what list 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

      • ListDiff

        public ListDiff()
    • Method Detail

      • getDifferences

        public abstract ListDiffEntry<E>[] getDifferences()
        Returns a ListDiffEntry array representing the differences in the list, in the order they are to be processed.

        This method returns identical results to getDifferencesAsList except that the results are returned as a array and so the ListDiffEntry objects are not properly typed. This form is here for compatibility. Use getDifferencesAsList to get typed results.

        Returns:
        a ListDiffEntry array representing the differences in the list, in the order they are to be processed.
      • isEmpty

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

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

        public java.util.List<E> simulateOn​(java.util.List<E> list)
        Returns a list showing what list would look like if this diff were applied to it.

        Note: the returned list is only valid until structural changes are made to the passed-in list.

        Parameters:
        list - the list over which the diff will be simulated
        Returns:
        an unmodifiable list showing what list would look like if it were passed to the applyTo(List) method.
        Since:
        1.3
        See Also:
        applyTo(List)
      • toString

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