本文整理汇总了Java中org.voltdb.types.ExpressionType.CONJUNCTION_AND属性的典型用法代码示例。如果您正苦于以下问题:Java ExpressionType.CONJUNCTION_AND属性的具体用法?Java ExpressionType.CONJUNCTION_AND怎么用?Java ExpressionType.CONJUNCTION_AND使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.voltdb.types.ExpressionType
的用法示例。
在下文中一共展示了ExpressionType.CONJUNCTION_AND属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: conjunction
/**
* Handy method for creating a conjunction expression. Multiple expressions
* can be given and they will all be joined with the same type.
*
* @param type
* The type of conjunction.
* @param exps
* The expressions to conjunct.
* @return The expression representing the conjunction.
*/
public static Expression conjunction(ExpressionType type, Expression... exps) {
Expression prev = null;
for (Expression exp : exps) {
if (prev != null) {
if (type == ExpressionType.CONJUNCTION_AND)
prev = new ConjunctionAnd(prev, exp);
else if (type == ExpressionType.CONJUNCTION_OR)
prev = new ConjunctionOr(prev, exp);
else
throw new IllegalArgumentException("Type must be a conjunction type");
} else {
prev = exp;
}
}
return prev;
}
示例2: combine
/**
*
* @param exps
*/
public static AbstractExpression combine(List<AbstractExpression> exps) {
Stack<AbstractExpression> stack = new Stack<AbstractExpression>();
stack.addAll(exps);
if (stack.isEmpty()) {
return null;
} else if (stack.size() == 1) {
return stack.pop();
}
AbstractExpression ret = null;
while (stack.size() > 1) {
AbstractExpression child_exp = stack.pop();
//
// If our return node is null, then we need to make a new one
//
if (ret == null) {
ret = new ConjunctionExpression(ExpressionType.CONJUNCTION_AND);
ret.setLeft(child_exp);
//
// Check whether we can add it to the right side
//
} else if (ret.getRight() == null) {
ret.setRight(child_exp);
stack.push(ret);
ret = null;
}
}
if (ret == null) {
ret = stack.pop();
} else {
ret.setRight(stack.pop());
}
return ret;
}