/** * PUBLIC: * Return a new expression that applies the function to the given expression. */ public static Expression subtract(Expression left, int right) { return subtract(left, Integer.valueOf(right)); }
/** * PUBLIC: * Return a new expression that applies the function to the given expression. */ public static Expression subtract(Expression left, int right) { return subtract(left, Integer.valueOf(right)); }
/** * PUBLIC: * Return a new expression that applies the function to the given expression. */ public static Expression subtract(Expression left, int right) { return subtract(left, new Integer(right)); }
/** * Create an expression that returns the difference between its arguments. * * @param x * expression * @param y * value * @return difference */ public <N extends Number> Expression<N> diff(Expression<? extends N> x, N y){ List list = new ArrayList(); list.add(x); list.add(this.internalLiteral(y)); return new FunctionExpressionImpl(this.metamodel, y.getClass(), ExpressionMath.subtract(((InternalSelection)x).getCurrentNode(), y), list, "diff"); }
/** * Create an expression that returns the difference between its arguments. * * @param x * expression * @param y * expression * @return difference */ public <N extends Number> Expression<N> diff(Expression<? extends N> x, Expression<? extends N> y){ List list = new ArrayList(); list.add(x); list.add(y); return new FunctionExpressionImpl(this.metamodel, x.getJavaType(), ExpressionMath.subtract(((InternalSelection)x).getCurrentNode(), ((InternalSelection)y).getCurrentNode()), list, "diff"); }
/** * {@inheritDoc} */ @Override public void visit(SubtractionExpression expression) { List<Class<?>> types = new ArrayList<Class<?>>(2); // Create the left side of the subtraction expression expression.getLeftExpression().accept(this); Expression leftExpression = queryExpression; types.add(type[0]); // Create the right side of the subtraction expression expression.getRightExpression().accept(this); Expression rightExpression = queryExpression; types.add(type[0]); // Now create the subtraction expression queryExpression = ExpressionMath.subtract(leftExpression, rightExpression); // Set the expression type Collections.sort(types, NumericTypeComparator.instance()); type[0] = types.get(0); }
/** * {@inheritDoc} */ @Override public void visit(SubtractionExpression expression) { List<Class<?>> types = new ArrayList<Class<?>>(2); // Create the left side of the subtraction expression expression.getLeftExpression().accept(this); Expression leftExpression = queryExpression; types.add(type[0]); // Create the right side of the subtraction expression expression.getRightExpression().accept(this); Expression rightExpression = queryExpression; types.add(type[0]); // Now create the subtraction expression queryExpression = ExpressionMath.subtract(leftExpression, rightExpression); // Set the expression type Collections.sort(types, NumericTypeComparator.instance()); type[0] = types.get(0); }
/** * INTERNAL * Generate the expression. */ public Expression generateExpression(GenerationContext context) { Expression whereClause = new ConstantExpression(new Integer(0), new ExpressionBuilder()); whereClause = ExpressionMath.subtract(whereClause, getLeft().generateExpression(context)); return whereClause; }
/** * Create an expression that returns the difference between its arguments. * * @param x * value * @param y * expression * @return difference */ public <N extends Number> Expression<N> diff(N x, Expression<? extends N> y){ List list = new ArrayList(); ExpressionImpl literal = (ExpressionImpl) this.internalLiteral(x); list.add(literal); list.add(y); return new FunctionExpressionImpl(this.metamodel, literal.getJavaType(), ExpressionMath.subtract(((InternalSelection)literal).getCurrentNode(), ((InternalSelection)y).getCurrentNode()), list, "diff"); }
/** * INTERNAL * Generate the expression. */ public Expression generateExpression(GenerationContext context) { Expression whereClause = new ConstantExpression(Integer.valueOf(0), new ExpressionBuilder()); whereClause = ExpressionMath.subtract(whereClause, getLeft().generateExpression(context)); return whereClause; }
/** * INTERNAL * Generate the expression. */ public Expression generateExpression(GenerationContext context) { Expression whereClause = new ConstantExpression(Integer.valueOf(0), new ExpressionBuilder()); whereClause = ExpressionMath.subtract(whereClause, getLeft().generateExpression(context)); return whereClause; }
/** * INTERNAL * Generate the expression. The steps are: * 1. Generate the expression for the left node * 2. Add the .subtract to the where clause returned from step 1 * 3. Generate the expression for the right side and use it as the parameter for the .subtract() * 4. Return the completed where clause to the caller */ public Expression generateExpression(GenerationContext context) { Expression whereClause = getLeft().generateExpression(context); whereClause = ExpressionMath.subtract(whereClause, getRight().generateExpression(context)); return whereClause; }
/** * INTERNAL * Generate the expression. The steps are: * 1. Generate the expression for the left node * 2. Add the .subtract to the where clause returned from step 1 * 3. Generate the expression for the right side and use it as the parameter for the .subtract() * 4. Return the completed where clause to the caller */ public Expression generateExpression(GenerationContext context) { Expression whereClause = getLeft().generateExpression(context); whereClause = ExpressionMath.subtract(whereClause, getRight().generateExpression(context)); return whereClause; }
/** * INTERNAL * Generate the expression. The steps are: * 1. Generate the expression for the left node * 2. Add the .subtract to the where clause returned from step 1 * 3. Generate the expression for the right side and use it as the parameter for the .subtract() * 4. Return the completed where clause to the caller */ public Expression generateExpression(GenerationContext context) { Expression whereClause = getLeft().generateExpression(context); whereClause = ExpressionMath.subtract(whereClause, getRight().generateExpression(context)); return whereClause; }
/** * {@inheritDoc} */ @Override public void visit(ArithmeticFactor expression) { // First create the Expression that is prepended with the unary sign expression.getExpression().accept(this); Expression arithmeticFactor = queryExpression; // Create an expression for the constant 0 (zero) queryExpression = new ConstantExpression(0, new ExpressionBuilder()); // "- <something>" is really "0 - <something>" queryExpression = ExpressionMath.subtract(queryExpression, arithmeticFactor); // Note: The type will be calculated when traversing the sub-expression }
/** * {@inheritDoc} */ @Override public void visit(ArithmeticFactor expression) { // First create the Expression that is prepended with the unary sign expression.getExpression().accept(this); Expression arithmeticFactor = queryExpression; // Create an expression for the constant 0 (zero) queryExpression = new ConstantExpression(0, new ExpressionBuilder()); // "- <something>" is really "0 - <something>" queryExpression = ExpressionMath.subtract(queryExpression, arithmeticFactor); // Note: The type will be calculated when traversing the sub-expression }