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

org.joo.libra.common.BinaryPredicate Maven / Gradle / Ivy

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy