com.link_intersystems.util.Predicates Maven / Gradle / Ivy
package com.link_intersystems.util;
import java.util.Objects;
import java.util.function.Predicate;
/**
* @author René Link {@literal }
*/
public class Predicates {
public static Predicate firstPredicate() {
return new Predicate() {
private boolean first = true;
@Override
public boolean test(T t) {
if (first) {
first = false;
return true;
}
return false;
}
};
}
public static Predicate equal(T equalTo) {
return equal(Objects::equals, equalTo);
}
public static Predicate equal(Equality equality, T equalTo) {
return t -> equality.isEqual(t, equalTo);
}
}