![JAR search and dependency download from the Maven repository](/logo.png)
org.joo.libra.logic.EqualsPredicate 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.logic;
import org.joo.libra.common.BinaryPredicate;
import org.joo.libra.common.HasValue;
import org.joo.libra.support.NumericComparator;
/**
* Represents a 'equal' predicate. It is used to check if both objects are equal
* to each other. If both object are Number
, they will be converted
* to {@link java.math.BigDecimal} before comparing, so 5
,
* 5.0
and 5L
are equally. Otherwise they will be
* compared using equals
method.
*
* @author griever
*
*/
@SuppressWarnings("rawtypes")
public class EqualsPredicate extends BinaryPredicate {
@SuppressWarnings("unchecked")
public EqualsPredicate(final HasValue> one, final HasValue> other) {
super(one, other);
}
@Override
protected boolean doSatisifiedBy(final Object one, final Object other) {
if (one instanceof Number && other instanceof Number) {
return NumericComparator.compare((Number) one, (Number) other) == 0;
}
return one.equals(other);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy