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

org.simpleflatmapper.util.EqualsPredicate Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

There is a newer version: 9.0.2
Show newest version
package org.simpleflatmapper.util;

public class EqualsPredicate implements Predicate{

    public final T expected;

    private EqualsPredicate(T expected) {
        this.expected = expected;
    }

    @Override
    public boolean test(T t) {
        return expected == null ? t == null : expected.equals(t);
    }
    
    
    public static  EqualsPredicate of(T value) {
        return new EqualsPredicate(value);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        EqualsPredicate that = (EqualsPredicate) o;

        return expected != null ? expected.equals(that.expected) : that.expected == null;
    }

    @Override
    public int hashCode() {
        return expected != null ? expected.hashCode() : 0;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy