org.simpleflatmapper.util.EqualsPredicate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sfm-util Show documentation
Show all versions of sfm-util Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
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;
}
}