org.joo.libra.common.BinaryPredicate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of joo-libra Show documentation
Show all versions of joo-libra Show documentation
Java Predicate with SQL-like syntax support
package org.joo.libra.common;
import org.joo.libra.PredicateContext;
public abstract class BinaryPredicate extends CompositionPredicate {
private HasValue one;
private HasValue other;
public BinaryPredicate(HasValue one, HasValue other) {
this.one = one;
this.other = other;
}
@Override
public boolean satisfiedBy(PredicateContext context) {
T theOne = one != null ? one.getValue(context) : null;
H theOther = other != null ? other.getValue(context) : null;
if (theOne == null && theOther == null)
return true;
if (theOne == null || theOther == null)
return false;
return doSatisifiedBy(theOne, theOther);
}
protected abstract boolean doSatisifiedBy(T one, H other);
}