difflib.DeltaComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of diffutils Show documentation
Show all versions of diffutils Show documentation
The DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java.
The newest version!
package difflib;
import java.io.Serializable;
import java.util.Comparator;
/**
* @author mksenzov
* @param T The type of the compared elements in the 'lines'.
*/
public class DeltaComparator implements Comparator>, Serializable {
private static final long serialVersionUID = 1L;
public static final Comparator> INSTANCE = new DeltaComparator();
private DeltaComparator() {
}
public int compare(final Delta> a, final Delta> b) {
final int posA = a.getOriginal().getPosition();
final int posB = b.getOriginal().getPosition();
if (posA > posB) {
return 1;
} else if (posA < posB) {
return -1;
}
return 0;
}
}