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

com.link_intersystems.util.Predicates Maven / Gradle / Ivy

Go to download

There is a newer version: 1.9.7
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy