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

io.cucumber.datatable.dependency.difflib.DeltaComparator Maven / Gradle / Ivy

package io.cucumber.datatable.dependency.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