Class Delta<T>

  • Type Parameters:
    T - The type of the compared elements in the 'lines'.
    Direct Known Subclasses:
    ChangeDelta, DeleteDelta, InsertDelta

    public abstract class Delta<T>
    extends java.lang.Object
    Initially copied from https://code.google.com/p/java-diff-utils/.

    Describes the delta between original and revised texts.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Delta.TYPE
      Specifies the type of the delta.
    • Constructor Summary

      Constructors 
      Constructor Description
      Delta​(Chunk<T> original, Chunk<T> revised)
      Construct the delta for original and revised chunks
    • Field Detail

      • original

        private Chunk<T> original
        The original chunk.
      • revised

        private Chunk<T> revised
        The revised chunk.
    • Constructor Detail

      • Delta

        public Delta​(Chunk<T> original,
                     Chunk<T> revised)
        Construct the delta for original and revised chunks
        Parameters:
        original - Chunk describing the original text. Must not be null.
        revised - Chunk describing the revised text. Must not be null.
    • Method Detail

      • verify

        public abstract void verify​(java.util.List<T> target)
                             throws java.lang.IllegalStateException
        Verifies that this delta can be used to patch the given text.
        Parameters:
        target - the text to patch.
        Throws:
        java.lang.IllegalStateException - if the patch cannot be applied.
      • applyTo

        public abstract void applyTo​(java.util.List<T> target)
                              throws java.lang.IllegalStateException
        Applies this delta as the patch for a given target
        Parameters:
        target - the given target
        Throws:
        java.lang.IllegalStateException - if verify(List) fails
      • getType

        public abstract Delta.TYPE getType()
        Returns the type of delta
        Returns:
        the type enum
      • getOriginal

        public Chunk<T> getOriginal()
        Returns:
        The Chunk describing the original text.
      • getRevised

        public Chunk<T> getRevised()
        Returns:
        The Chunk describing the revised text.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • lineNumber

        public int lineNumber()
      • toString

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