Class Diff<T>

  • Type Parameters:
    T - the type of object represented by the diff

    public class Diff<T>
    extends Object
    Class representing one diff operation.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Diff.Operation
      The data structure representing a diff is a Linked list of Diff objects: {Diff(Operation.DELETE, "Hello"), Diff(Operation.INSERT, "Goodbye"), Diff(Operation.EQUAL, " world.")} which means: delete "Hello", add "Goodbye" and keep " world."
    • Field Summary

      Fields 
      Modifier and Type Field Description
      List<T> list
      The text associated with this diff operation.
      Diff.Operation operation
      One of: INSERT, DELETE or EQUAL.
    • Constructor Summary

      Constructors 
      Constructor Description
      Diff​(Diff.Operation operation, List<T> list)
      Constructor.
    • Field Detail

      • operation

        public Diff.Operation operation
        One of: INSERT, DELETE or EQUAL.
      • list

        public List<T> list
        The text associated with this diff operation.
    • Constructor Detail

      • Diff

        public Diff​(Diff.Operation operation,
                    List<T> list)
        Constructor. Initializes the diff with the provided values.
        Parameters:
        operation - One of INSERT, DELETE or EQUAL.
        list - The text being applied.
    • Method Detail

      • toString

        public String toString()
        Display a human-readable version of this Diff.
        Overrides:
        toString in class Object
        Returns:
        text version.
      • equals

        public boolean equals​(Object d)
        Is this Diff equivalent to another Diff?
        Overrides:
        equals in class Object
        Parameters:
        d - Another Diff to compare against.
        Returns:
        true or false.