/** * PUBLIC: * Return a new expression that applies the function to the given expression. */ public static Expression divide(Expression left, int right) { return divide(left, Integer.valueOf(right)); }
/** * PUBLIC: * Return a new expression that applies the function to the given expression. */ public static Expression divide(Expression left, int right) { return divide(left, Integer.valueOf(right)); }
/** * PUBLIC: * Return a new expression that applies the function to the given expression. */ public static Expression divide(Expression left, int right) { return divide(left, new Integer(right)); }
/** * {@inheritDoc} */ @Override public void visit(DivisionExpression expression) { List<Class<?>> types = new ArrayList<Class<?>>(2); // Create the left side of the division expression expression.getLeftExpression().accept(this); Expression leftExpression = queryExpression; types.add(type[0]); // Create the right side of the division expression expression.getRightExpression().accept(this); Expression rightExpression = queryExpression; types.add(type[0]); // Now create the division expression queryExpression = ExpressionMath.divide(leftExpression, rightExpression); // Set the expression type Collections.sort(types, NumericTypeComparator.instance()); type[0] = types.get(0); }
/** * {@inheritDoc} */ @Override public void visit(DivisionExpression expression) { List<Class<?>> types = new ArrayList<Class<?>>(2); // Create the left side of the division expression expression.getLeftExpression().accept(this); Expression leftExpression = queryExpression; types.add(type[0]); // Create the right side of the division expression expression.getRightExpression().accept(this); Expression rightExpression = queryExpression; types.add(type[0]); // Now create the division expression queryExpression = ExpressionMath.divide(leftExpression, rightExpression); // Set the expression type Collections.sort(types, NumericTypeComparator.instance()); type[0] = types.get(0); }
/** * INTERNAL * Generate the expression. The steps are: * 1. Generate the expression for the left node * 2. Add the .divide to the where clause returned from step 1 * 3. Generate the expression for the right side and use it as the parameter for the .divide() * 4. Return the completed where clause to the caller */ public Expression generateExpression(GenerationContext context) { Expression whereClause = getLeft().generateExpression(context); whereClause = ExpressionMath.divide(whereClause, getRight().generateExpression(context)); return whereClause; }
/** * INTERNAL * Generate the expression. The steps are: * 1. Generate the expression for the left node * 2. Add the .divide to the where clause returned from step 1 * 3. Generate the expression for the right side and use it as the parameter for the .divide() * 4. Return the completed where clause to the caller */ public Expression generateExpression(GenerationContext context) { Expression whereClause = getLeft().generateExpression(context); whereClause = ExpressionMath.divide(whereClause, getRight().generateExpression(context)); return whereClause; }
/** * INTERNAL * Generate the expression. The steps are: * 1. Generate the expression for the left node * 2. Add the .divide to the where clause returned from step 1 * 3. Generate the expression for the right side and use it as the parameter for the .divide() * 4. Return the completed where clause to the caller */ public Expression generateExpression(GenerationContext context) { Expression whereClause = getLeft().generateExpression(context); whereClause = ExpressionMath.divide(whereClause, getRight().generateExpression(context)); return whereClause; }
/** * Create an expression that returns the quotient of its arguments. * * @param x * expression * @param y * value * @return quotient */ public Expression<Number> quot(Expression<? extends Number> x, Number y){ return new FunctionExpressionImpl(this.metamodel, (Class)BasicTypeHelperImpl.getInstance().extendedBinaryNumericPromotion(x.getJavaType(), y.getClass()), ExpressionMath.divide(((InternalSelection)x).getCurrentNode(),y), buildList(x,internalLiteral(y)), "quot"); }
/** * Create an expression that returns the quotient of its arguments. * * @param x * expression * @param y * expression * @return quotient */ public Expression<Number> quot(Expression<? extends Number> x, Expression<? extends Number> y){ return new FunctionExpressionImpl(this.metamodel, (Class)BasicTypeHelperImpl.getInstance().extendedBinaryNumericPromotion(x.getJavaType(), y.getClass()), ExpressionMath.divide(((InternalSelection)x).getCurrentNode(),((InternalSelection)y).getCurrentNode()), buildList(x,y), "quot"); }
/** * Create an expression that returns the quotient of its arguments. * * @param x * value * @param y * expression * @return quotient */ public Expression<Number> quot(Number x, Expression<? extends Number> y){ return new FunctionExpressionImpl(this.metamodel, ClassConstants.NUMBER, ExpressionMath.divide(new ConstantExpression(x, ((InternalSelection)y).getCurrentNode()),((InternalSelection)y).getCurrentNode()), buildList(internalLiteral(x),y), "quot"); }