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

com.jnape.palatable.lambda.functions.builtin.fn2.Eq Maven / Gradle / Ivy

package com.jnape.palatable.lambda.functions.builtin.fn2;

import com.jnape.palatable.lambda.functions.specialized.BiPredicate;
import com.jnape.palatable.lambda.functions.specialized.Predicate;

/**
 * Type-safe equality in function form; uses {@link Object#equals}, not ==.
 *
 * @param  the type to compare for equality
 */
public final class Eq implements BiPredicate {

    private Eq() {
    }

    @Override
    public Boolean apply(A x, A y) {
        return x == null ? y == null : x.equals(y);
    }

    public static  Eq eq() {
        return new Eq<>();
    }

    public static  Predicate eq(A x) {
        return Eq.eq().apply(x);
    }

    public static  Boolean eq(A x, A y) {
        return eq(x).apply(y);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy