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

com.github.leeonky.util.function.Comparator Maven / Gradle / Ivy

The newest version!
package com.github.leeonky.util.function;

public interface Comparator> {
    static > Comparator lessThan(V target) {
        return value -> value.compareTo(target) < 0;
    }

    static > Comparator equalTo(V target) {
        return value -> value.compareTo(target) == 0;
    }

    static > Comparator greaterThan(V target) {
        return not(lessOrEqualTo(target));
    }

    static > Comparator lessOrEqualTo(V target) {
        return lessThan(target).or(equalTo(target));
    }

    static > Comparator greaterOrEqualTo(V target) {
        return not(lessThan(target));
    }

    static > Comparator not(Comparator another) {
        return value -> !another.compareTo(value);
    }

    boolean compareTo(V value);

    default Comparator or(Comparator another) {
        return value -> compareTo(value) || another.compareTo(value);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy