return added.optimize(session);
}
}
}
// TODO optimization: convert .. OR .. to UNION if the cost is lower
Value l = left.isConstant() ? left.getValue(session) : null;
Value r = right.isConstant() ? right.getValue(session) : null;
if (l == null && r == null) {
return this;
}
if (l != null && r != null) {
return ValueExpression.get(getValue(session));
}
switch (andOrType) {
case AND:
if (l != null) {
if (Boolean.FALSE.equals(l.getBoolean())) {
return ValueExpression.get(l);
} else if (Boolean.TRUE.equals(l.getBoolean())) {
return right;
}
} else if (r != null) {
if (Boolean.FALSE.equals(r.getBoolean())) {
return ValueExpression.get(r);
} else if (Boolean.TRUE.equals(r.getBoolean())) {
return left;
}
}
break;
case OR:
if (l != null) {
if (Boolean.TRUE.equals(l.getBoolean())) {
return ValueExpression.get(l);
} else if (Boolean.FALSE.equals(l.getBoolean())) {
return right;
}
} else if (r != null) {
if (Boolean.TRUE.equals(r.getBoolean())) {
return ValueExpression.get(r);
} else if (Boolean.FALSE.equals(r.getBoolean())) {
return left;
}
}
break;
default: