Package org.assertj.core.util.diff.myers
Class MyersDiff<T>
java.lang.Object
org.assertj.core.util.diff.myers.MyersDiff<T>
- Type Parameters:
T- The type of the compared elements in the 'lines'.
- All Implemented Interfaces:
DiffAlgorithm<T>
Copy from https://code.google.com/p/java-diff-utils/.
A clean-room implementation of Eugene Myers differencing algorithm.
See the paper at http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionComputes the minimum diffpath that expresses de differences between the original and revised sequences, according to Gene Myers differencing algorithm.Constructs aPatchfrom a difference path.copyOfRange(List<T> original, int fromIndex, int to) Creates a new list containing the elements returned byList.subList(int, int).Computes the difference between the original sequence and the revised sequence and returns it as aPatchobject.private boolean
-
Field Details
-
equalizer
The equalizer.
-
-
Constructor Details
-
MyersDiff
public MyersDiff()Constructs an instance of the Myers differencing algorithm.
-
-
Method Details
-
diff
Computes the difference between the original sequence and the revised sequence and returns it as aPatchobject. Return empty diff if get the error while procession the difference.- Specified by:
diffin interfaceDiffAlgorithm<T>- Parameters:
original- The original sequence. Must not benull.revised- The revised sequence. Must not benull.- Returns:
- The patch representing the diff of the given sequences. Never
null.
-
buildPath
Computes the minimum diffpath that expresses de differences between the original and revised sequences, according to Gene Myers differencing algorithm.- Parameters:
orig- The original sequence.rev- The revised sequence.- Returns:
- A minimum
Pathacross the differences graph. - Throws:
IllegalStateException- if a diff path could not be found.
-
equals
-
buildRevision
Constructs aPatchfrom a difference path.- Parameters:
path- The path.orig- The original sequence.rev- The revised sequence.- Returns:
- A
Patchscript corresponding to the path.
-
copyOfRange
Creates a new list containing the elements returned byList.subList(int, int).- Parameters:
original- The original sequence. Must not benull.fromIndex- low endpoint (inclusive) of the subList.to- high endpoint (exclusive) of the subList.- Returns:
- A new list of the specified range within the original list.
-