public class Diff<T> extends Differ<T,Difference>
Comparator may be passed as an
argument to the constructor, and will thus be used. If not provided, the
initial value in the a ("from") collection will be looked at to
see if it supports the Comparable interface. If so, its
equals and compareTo methods will be invoked on the
instances in the "from" and "to" collections; otherwise, for speed, hash
codes from the objects will be used instead for comparison.
The file FileDiff.java shows an example usage of this class, in an application similar to the Unix "diff" program.
| Constructor and Description |
|---|
Diff(java.util.List<T> a,
java.util.List<T> b)
Constructs the Diff object for the two collections, using the default
comparison mechanism between the objects, such as
equals and
compareTo. |
Diff(java.util.List<T> a,
java.util.List<T> b,
java.util.Comparator<T> comp)
Constructs the Diff object for the two collections, using the given
comparator.
|
Diff(T[] a,
T[] b)
Constructs the Diff object for the two arrays, using the default
comparison mechanism between the objects, such as
equals and
compareTo. |
Diff(T[] a,
T[] b,
java.util.Comparator<T> comp)
Constructs the Diff object for the two arrays, using the given comparator.
|
| Modifier and Type | Method and Description |
|---|---|
Difference |
createDifference(java.lang.Integer delStart,
java.lang.Integer delEnd,
java.lang.Integer addStart,
java.lang.Integer addEnd)
Returns a legacy
Difference See Differ to
return a subclass of Difference. |
addPending, diff, execute, onFromNotTo, onMatch, onToNotFrom, traverseEndOfSequences, traverseSequencespublic Diff(T[] a, T[] b, java.util.Comparator<T> comp)
public Diff(T[] a, T[] b)
equals and
compareTo.public Diff(java.util.List<T> a, java.util.List<T> b)
equals and
compareTo.public Difference createDifference(java.lang.Integer delStart, java.lang.Integer delEnd, java.lang.Integer addStart, java.lang.Integer addEnd)
Difference See Differ to
return a subclass of Difference.createDifference in class Differ<T,Difference>