com.link_intersystems.util.Predicates Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lis-commons-util Show documentation
Show all versions of lis-commons-util Show documentation
Link Intersystems Commons Util (lis-commons-util) is collection of reusable software components
that extend the standard java.util components.
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);
}
}