All Downloads are FREE. Search and download functionalities are using the official Maven repository.

difflib.DeltaComparator Maven / Gradle / Ivy

Go to download

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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy