/*
(non-Javadoc)

@see
javax.persistence.criteria.CriteriaBuilder#or(javax.persistence.criteria
.Expression, javax.persistence.criteria.Expression)
1943
@Override
    public Predicate or(Expression<Boolean> arg0, Expression<Boolean> arg1)
    {
        // TODO Auto-generated method stub
        if (arg0 != null && arg1 != null)
        {
            if (arg0.getClass().isAssignableFrom(ComparisonPredicate.class) && arg1.getClass().isAssignableFrom(ComparisonPredicate.class))
            {
                return new DisjunctionPredicate((Predicate)arg0, (Predicate)arg1);
            }
        }
        return null;
    }
504956
public OptionalSyntax where(Expression<?>... expression) {
		for (Expression<?> exp : expression) {
			getMessage().getOptional().add(exp.toString());
			LOG.debug("expression: " + exp);
		}
		QueryMessage mess = getMessage();
		return new OptionalSyntax(mess);
	}
1150963
protected AstNode or(boolean required) throws ScanException, ParseException {
		AstNode v = and(required);
		if (v == null) {
			return null;
		}
		while (true) {
			switch (token.getSymbol()) {
				case OR:
					consumeToken();
					v = createAstBinary(v, and(true), AstBinary.OR);
					break;
				case EXTENSION:
					if (getExtensionHandler(token).getExtensionPoint() == ExtensionPoint.OR) {
						v = getExtensionHandler(consumeToken()).createAstNode(v, and(true));
						break;
					}
				default:
					return v;
			}
		}
	}
133850
public ZealotKhala orIn(String field, Object[] values) {
        return this.doIn(ZealotConst.OR_PREFIX, field, values, true, true);
    }
847409
public static <T> JDOQuery<T> select(Expression<T> expr) {
        return new JDOQuery<Void>().select(expr);
    }
784139
public ExpressionBuilder or() {
		GroupExpression lastGroupExpression = stack.isEmpty() ? null : stack.peek();

		if (lhsExpression == null) {
			throw new SyntaxException("Syntax exception: OR missing LHS operand");
		} else if (lastGroupExpression == null) {
			GroupExpression or = new GroupExpression(GroupExpression.Type.OR);
			or.add(lhsExpression);
			stack.push(or);
			expression.setExpression(or);
			lhsExpression = null;
		} else if (lastGroupExpression.getType().equals(GroupExpression.Type.OR)) {
			// Keep using the existing OR
			lhsExpression = null;
			return this;
		} else if (lastGroupExpression.getType().equals(GroupExpression.Type.AND)) {
			// AND takes precedence over OR, so we wrap the AND
			// by removing it from any parent expressions and inserting the OR in its place

			GroupExpression and = stack.pop();
			GroupExpression or = new GroupExpression(GroupExpression.Type.OR);

			if (stack.isEmpty()) {
				expression.setExpression(or);
				or.add(and);
			} else {
				// need to get at the parent
				GroupExpression parent = stack.pop();
				parent.remove(and);
				parent.add(or);
				or.add(and);
			}

			stack.push(and);
			stack.push(or);
			lhsExpression = null;
		}

		return this;
	}
253089
public static <T> Predicate<T> or(Predicate<? super T>... components) {
        return or(Arrays.asList(components));
    }
1070558
private Object evaluateRoleExpression(ActionBean bean, String expression)
	{
		try
		{
			LOG.debug("Evaluating expression: '" + expression + '\'');

			// This is somewhat of a hack until the ExpressionEvaluator becomes more accessible.
			ParameterName name = new ParameterName("security");
			List<Object> values = new ArrayList<Object>();
			values.add(null);
			ValidationMetadata metadata = new ValidationMetadata("security").expression(expression);
			ValidationErrors errors = new ValidationErrors();

			ExpressionValidator.evaluate(bean, name, values, metadata, errors);

			return errors.isEmpty();
		}
		catch (Exception exc)
		{
			throw new StripesRuntimeException(exc);
		}
	}
1201964
private AndQueryBuilder getAndFilterBuilder(Expression logicalExp, EntityMetadata m)
    {
        AndExpression andExp = (AndExpression) logicalExp;
        Expression leftExpression = andExp.getLeftExpression();
        Expression rightExpression = andExp.getRightExpression();

        return new AndQueryBuilder(populateFilterBuilder(leftExpression, m), populateFilterBuilder(rightExpression, m));
    }
33685
@NonNull
    public Expression in(@NonNull Expression... expressions) {
        if (expressions == null) {
            throw new IllegalArgumentException("expressions cannot be null.");
        }
        final Expression aggr = new AggregateExpression(Arrays.asList(expressions));
        return new BinaryExpression(this, aggr, BinaryExpression.OpType.In);
    }
86970
public BooleanBuilder or(@Nullable Predicate right) {
        if (right != null) {
            if (predicate == null) {
                predicate = right;
            } else {
                predicate = ExpressionUtils.or(predicate, right);
            }
        }
        return this;
    }
683292
private OrQueryBuilder getOrFilterBuilder(Expression logicalExp, EntityMetadata m)
    {
        OrExpression orExp = (OrExpression) logicalExp;
        Expression leftExpression = orExp.getLeftExpression();
        Expression rightExpression = orExp.getRightExpression();

        return new OrQueryBuilder(populateFilterBuilder(leftExpression, m), populateFilterBuilder(rightExpression, m));
    }
711714
public static void traverse(Expression expression, EntityMetadata m, KunderaMetadata kunderaMetadata,
            KunderaQuery kunderaQuery, boolean isSubExpression)
    {

        if (ComparisonExpression.class.isAssignableFrom(expression.getClass()))
        {
            onComparisonExpression(expression, m, kunderaMetadata, kunderaQuery);
        }
        else if (NullComparisonExpression.class.isAssignableFrom(expression.getClass()))
        {
            onNullComparisonExpression(expression, m, kunderaMetadata, kunderaQuery);
        }
        else if (LogicalExpression.class.isAssignableFrom(expression.getClass()))
        {
            onLogicalExpression(expression, m, kunderaMetadata, kunderaQuery);
        }
        else if (InExpression.class.isAssignableFrom(expression.getClass()))
        {
            onInExpression(expression, m, kunderaMetadata, kunderaQuery);
        }
        else if (LikeExpression.class.isAssignableFrom(expression.getClass()))
        {
            onLikeExpression(expression, m, kunderaMetadata, kunderaQuery);
        }
        else if (RegexpExpression.class.isAssignableFrom(expression.getClass()))
        {
            onRegExpression(expression, m, kunderaMetadata, kunderaQuery);
        }
        else if (BetweenExpression.class.isAssignableFrom(expression.getClass()))
        {
            onBetweenExpression(expression, m, kunderaMetadata, kunderaQuery);
        }
        else if (SubExpression.class.isAssignableFrom(expression.getClass()))
        {
            onSubExpression(expression, m, kunderaMetadata, kunderaQuery);
        }

    }
860531
public final BooleanExpression between(@Nullable T from, @Nullable T to) {
        if (from == null) {
            if (to != null) {
                return Expressions.booleanOperation(Ops.LOE, mixin, ConstantImpl.create(to));
            } else {
                throw new IllegalArgumentException("Either from or to needs to be non-null");
            }
        } else if (to == null) {
            return Expressions.booleanOperation(Ops.GOE, mixin, ConstantImpl.create(from));
        } else {
            return Expressions.booleanOperation(Ops.BETWEEN, mixin, ConstantImpl.create(from), ConstantImpl.create(to));
        }
    }
853854
@SuppressWarnings("unchecked")
    public static <T> Expression<T> any(SubQueryExpression<? extends T> col) {
        return new OperationImpl<T>(col.getType(), Ops.QuantOps.ANY, ImmutableList.<Expression<?>>of(col));
    }
267157
public final <A extends Number & Comparable<?>> BooleanExpression between(@Nullable A from, @Nullable A to) {
        if (from == null) {
            if (to != null) {
                return loe(to);
            } else {
                throw new IllegalArgumentException("Either from or to needs to be non-null");
            }
        } else if (to == null) {
            return goe(from);
        } else {
            return between(ConstantImpl.create(cast(from)), ConstantImpl.create(cast(to)));
        }
    }
128166
@NonNull
    public ArrayExpressionSatisfies in(@NonNull Expression expression) {
        if (expression == null) {
            throw new IllegalArgumentException("expression cannot be null.");
        }
        return new ArrayExpressionSatisfies(type, variable, expression);
    }