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

cucumber.runtime.HookComparator Maven / Gradle / Ivy

There is a newer version: 7.18.1
Show newest version
package cucumber.runtime;

import java.util.Comparator;

class HookComparator implements Comparator {
    private final boolean ascending;

    public HookComparator(boolean ascending) {
        this.ascending = ascending;
    }

    @Override
    public int compare(HookDefinition hook1, HookDefinition hook2) {
        int x = hook1.getOrder();
        int y = hook2.getOrder();
        // TODO Java7 PR #1147: Inlined Integer.compare. Not available in java 6 yet.
        int comparison = (x < y) ? -1 : ((x == y) ? 0 : 1);
        return ascending ? comparison : -comparison;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy