Class Diff<T>

java.lang.Object
org.webcat.diff.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 enum 
    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
    The text associated with this diff operation.
    One of: INSERT, DELETE or EQUAL.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Diff(Diff.Operation operation, List<T> list)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Is this Diff equivalent to another Diff?
    Display a human-readable version of this Diff.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • operation

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

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

    • 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 Details

    • 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.