@Override
@SuppressWarnings("unchecked")
protected boolean evaluateExpression(final ORecordInternal<?> iRecord, final OSQLFilterCondition iCondition, final Object iLeft,
final Object iRight) {
final OSQLFilterCondition condition;
if (iCondition.getLeft() instanceof OSQLFilterCondition)
condition = (OSQLFilterCondition) iCondition.getLeft();
else if (iCondition.getRight() instanceof OSQLFilterCondition)
condition = (OSQLFilterCondition) iCondition.getRight();
else
condition = null;
if (iLeft instanceof Collection<?>) {
final Collection<ORecordSchemaAware<?>> collection = (Collection<ORecordSchemaAware<?>>) iLeft;
if (condition != null) {
// CHECK AGAINST A CONDITION
for (final ORecordSchemaAware<?> o : collection) {
if ((Boolean) condition.evaluate(o) == Boolean.FALSE)
return false;
}
} else {
// CHECK AGAINST A SINGLE VALUE
for (final Object o : collection) {
if (!OQueryOperatorEquals.equals(iRight, o))
return false;
}
}
} else if (iRight instanceof Collection<?>) {
// CHECK AGAINST A CONDITION
final Collection<ORecordSchemaAware<?>> collection = (Collection<ORecordSchemaAware<?>>) iRight;
if (condition != null) {
for (final ORecordSchemaAware<?> o : collection) {
if ((Boolean) condition.evaluate(o) == Boolean.FALSE)
return false;
}
} else {
// CHECK AGAINST A SINGLE VALUE
for (final Object o : collection) {