public ArgumentListFunctionExpression coalesce() { ListExpressionOperator coalesceOperator = (ListExpressionOperator)getOperator(ExpressionOperator.Coalesce); ListExpressionOperator clonedCoalesceOperator = new ListExpressionOperator(); coalesceOperator.copyTo(clonedCoalesceOperator); ArgumentListFunctionExpression expression = new ArgumentListFunctionExpression(); expression.setBaseExpression(this); expression.setOperator(clonedCoalesceOperator); return expression; }
/** * INTERNAL: * Add a child and ensure it is the rightmost in the tree as long as it * is in the tree * If there is already a node that is set as therightmost node, replace it * @param argument */ public synchronized void addRightMostChild(Expression argument){ if (hasLastChild != null && hasLastChild.booleanValue()){ getChildren().remove(super.getChildren().size() - 1); super.addChild(argument); } else { this.addChild(argument); } this.hasLastChild = Boolean.valueOf(true); }
/** * INTERNAL: * Print SQL */ public void printSQL(ExpressionSQLPrinter printer) { ListExpressionOperator platformOperator = (ListExpressionOperator)getPlatformOperator(printer.getPlatform()); platformOperator.copyTo(operator); operator.printCollection(getChildren(), printer); }
/** * INTERNAL: * Add a new Expression to the list of arguments. * This method will update the list of arguments and any constant strings that are required * to be printed with the arguments * @param argument */ @Override public synchronized void addChild(Expression argument){ if (hasLastChild != null && hasLastChild.booleanValue()){ getChildren().add(getChildren().size() - 1, argument); } else { super.addChild(argument); } setBaseExpression(getChildren().firstElement()); ((ListExpressionOperator)operator).incrementNumberOfItems(); }
if (iterator.hasNext()){ Expression base = Expression.from(iterator.next(), this); expression.addChild(base); expression.setBaseExpression(base);//base needs to be the same as the first child for reportQuery items. while (iterator.hasNext()) { expression.addChild(Expression.from(iterator.next(), this));
/** * Create an expression that returns null if all its arguments evaluate to * null, and the value of the first non-null argument otherwise. * * @param x * expression * @param y * expression * @return expression corresponding to the given coalesce expression */ public <Y> Expression<Y> coalesce(Expression<? extends Y> x, Expression<? extends Y> y){ ArgumentListFunctionExpression coalesce = ((InternalSelection)x).getCurrentNode().coalesce(); coalesce.addChild(((InternalSelection)x).getCurrentNode()); coalesce.addChild(((InternalSelection)y).getCurrentNode()); return new CoalesceImpl(metamodel, x.getJavaType(), coalesce, buildList(x, y), "coalesce"); }
return new ArgumentListFunctionExpression(); } else if (this.nodeClass == ClassConstants.FunctionExpression_Class) { return new FunctionExpression();
/** * Add an "else" clause to the case expression. * @param result "else" result * @return expression */ public Expression<R> otherwise(R result){ org.eclipse.persistence.expressions.Expression resultExp = org.eclipse.persistence.expressions.Expression.from(result, new ExpressionBuilder()); ((ArgumentListFunctionExpression)currentNode).addRightMostChild(resultExp); return this; }
/** * INTERNAL: * Add a new Expression to the list of arguments. * This method will update the list of arguments and any constant strings that are required * to be printed with the arguments * @param argument */ @Override public synchronized void addChild(Expression argument){ if (hasLastChild != null && hasLastChild.booleanValue()){ getChildren().add(getChildren().size() - 1, argument); } else { super.addChild(argument); } setBaseExpression((Expression)getChildren().firstElement()); ((ListExpressionOperator)operator).incrementNumberOfItems(); }
if (iterator.hasNext()){ Expression base = Expression.from(iterator.next(), this); expression.addChild(base); expression.setBaseExpression(base);//base needs to be the same as the first child for reportQuery items. while (iterator.hasNext()) { expression.addChild(Expression.from(iterator.next(), this));
/** * Create an expression that returns null if all its arguments evaluate to * null, and the value of the first non-null argument otherwise. * * @param x * expression * @param y * value * @return coalesce expression */ public <Y> Expression<Y> coalesce(Expression<? extends Y> x, Y y){ ArgumentListFunctionExpression coalesce = ((InternalSelection)x).getCurrentNode().coalesce(); coalesce.addChild(((InternalSelection)x).getCurrentNode()); coalesce.addChild(((InternalSelection)y).getCurrentNode()); return new CoalesceImpl(metamodel, x.getJavaType(), coalesce, buildList(x, internalLiteral(y)), "coalesce"); }
return new ArgumentListFunctionExpression(); } else if (this.nodeClass == ClassConstants.FunctionExpression_Class) { return new FunctionExpression();
/** * Add an "else" clause to the case expression. * @param result "else" result expression * @return expression */ public Expression<R> otherwise(Expression<? extends R> result){ org.eclipse.persistence.expressions.Expression resultExp = ((InternalSelection)result).getCurrentNode(); resultExp = org.eclipse.persistence.expressions.Expression.from(resultExp, currentNode); ((ArgumentListFunctionExpression)currentNode).addRightMostChild(resultExp); return this; } }
public ArgumentListFunctionExpression coalesce() { ListExpressionOperator coalesceOperator = (ListExpressionOperator)getOperator(ExpressionOperator.Coalesce); ListExpressionOperator clonedCoalesceOperator = new ListExpressionOperator(); coalesceOperator.copyTo(clonedCoalesceOperator); ArgumentListFunctionExpression expression = new ArgumentListFunctionExpression(); expression.setBaseExpression(this); expression.setOperator(clonedCoalesceOperator); return expression; }
/** * INTERNAL: * Print SQL */ public void printSQL(ExpressionSQLPrinter printer) { ListExpressionOperator platformOperator = (ListExpressionOperator)getPlatformOperator(printer.getPlatform()); platformOperator.copyTo(operator); ((ListExpressionOperator)operator).setIsComplete(true); operator.printCollection(getChildren(), printer); }
/** * INTERNAL: * Add a new Expression to the list of arguments. * This method will update the list of arguments and any constant strings that are required * to be printed with the arguments * @param argument */ @Override public synchronized void addChild(Expression argument){ if (hasLastChild != null && hasLastChild.booleanValue()){ getChildren().add(getChildren().size() - 1, argument); } else { super.addChild(argument); } setBaseExpression((Expression)getChildren().firstElement()); ((ListExpressionOperator)operator).incrementNumberOfItems(); }
/** * INTERNAL: * Add a child and ensure it is the rightmost in the tree as long as it * is in the tree * If there is already a node that is set as therightmost node, replace it * @param argument */ public synchronized void addRightMostChild(Expression argument){ if (hasLastChild != null && hasLastChild.booleanValue()){ getChildren().remove(super.getChildren().size() - 1); super.addChild(argument); } else { this.addChild(argument); } this.hasLastChild = Boolean.TRUE; }
if (iterator.hasNext()){ Expression base = Expression.from(iterator.next(), this); expression.addChild(base); expression.setBaseExpression(base);//base needs to be the same as the first child for reportQuery items. while (iterator.hasNext()) { expression.addChild(Expression.from(iterator.next(), this));
/** * Add an "else" clause to the case expression. * @param result "else" result * @return expression */ public Expression<R> otherwise(R result){ org.eclipse.persistence.expressions.Expression resultExp = org.eclipse.persistence.expressions.Expression.from(result, new ExpressionBuilder()); ((ArgumentListFunctionExpression)currentNode).addRightMostChild(resultExp); return this; }
/** * INTERNAL: * Creates an ArgumentListFunctionExpression that is capable of creating a case statement of the form: * <blockquote><pre> * SQL: CASE WHEN name = "Robert" THEN "Bob" * WHEN name = "Susan" THEN "Sue" * ELSE "No-Nickname" * </pre></blockquote> * * This expression must be manipulated to successfully build a case statement by adding appropriate * children to it. * * A pair of children must be added for each "when then" expression and a child must be added for the else. * * @see ArgumentListFunctionExpression */ public ArgumentListFunctionExpression caseConditionStatement() { ListExpressionOperator caseOperator = (ListExpressionOperator)getOperator(ExpressionOperator.CaseCondition); ListExpressionOperator clonedCaseOperator = new ListExpressionOperator(); caseOperator.copyTo(clonedCaseOperator); ArgumentListFunctionExpression expression = new ArgumentListFunctionExpression(); expression.setBaseExpression(this); expression.setOperator(clonedCaseOperator); return expression; }