/** * INTERNAL: * Create an expression node. */ public static Expression fromConstant(Object value, Expression base) { return new ConstantExpression(value, base); }
/** * INTERNAL: * Create an expression node. */ public static Expression fromConstant(Object value, Expression base) { return new ConstantExpression(value, base); }
/** * PUBLIC: * Return an expression on the constant. * <p>Example: * <blockquote><pre> * reportQuery.addItem("a constant", builder.value("a constant")); * </pre></blockquote> */ public Expression value(Object constant) { return new ConstantExpression(constant, this); }
/** * INTERNAL: * Create an expression node. */ public static Expression fromConstant(Object value, Expression base) { return new ConstantExpression(value, base); }
/** * PUBLIC: * Return an expression on the constant. * <p>Example: * <pre><blockquote> * reportQuery.addItem("a constant", builder.value("a constant")); * </blockquote></pre> */ public Expression value(Object constant) { return new ConstantExpression(constant, this); }
/** * PUBLIC: * Return an expression that compares if the receivers value is not like the other value. * Equivalent to like negated. * @see #like(String) */ public Expression notLike(String aString) { return notLike(new ConstantExpression(aString, this)); }
/** * PUBLIC: * Return an expression that compares if the receivers value is not like the other value. * Equivalent to like negated. * @see #like(String) */ public Expression notLike(String aString) { return notLike(new ConstantExpression(aString, this)); }
/** * Create an expression literal but without null validation. * * @param value * @return expression literal */ protected <T> Expression<T> internalLiteral(T value){ return new ExpressionImpl<T>(metamodel, (Class<T>) (value == null? null: value.getClass()), new ConstantExpression(value, new ExpressionBuilder()), value); }
/** * Create an expression literal. * * @param value * @return expression literal */ public <T> Expression<T> literal(T value){ if (value == null) { throw new IllegalArgumentException( ExceptionLocalization.buildMessage("jpa_criteriaapi_null_literal_value", new Object[]{})); } return new ExpressionImpl<T>(metamodel, (Class<T>) (value.getClass()), new ConstantExpression(value, new ExpressionBuilder()), value); }
/** * Create an expression for a null literal with the given type. * * @param resultClass type of the null literal * @return null expression literal */ public <T> Expression<T> nullLiteral(Class<T> resultClass){ return new ExpressionImpl<T>(metamodel, resultClass, new ConstantExpression(null, new ExpressionBuilder()), null); }
/** * INTERNAL * Generate the a new EclipseLink ConstantExpression for this node. */ public Expression generateExpression(GenerationContext context) { Expression whereClause = new ConstantExpression(getLiteral(), context.getBaseExpression()); return whereClause; }
/** * {@inheritDoc} */ @Override public void visit(StringLiteral expression) { // Create the expression queryExpression = queryContext.getBaseExpression(); queryExpression = new ConstantExpression(expression.getUnquotedText(), queryExpression); // Set the expression type type[0] = String.class; }
/** * INTERNAL * Generate the a new EclipseLink ConstantExpression for this node. */ public Expression generateExpression(GenerationContext context) { Expression whereClause = new ConstantExpression(getLiteral(), context.getBaseExpression()); return whereClause; }
/** * 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"); }
/** * 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; }
/** * Create an expression that returns the sum of its arguments. * * @param x * value * @param y * expression * @return sum */ public <N extends Number> Expression<N> sum(N x, Expression<? extends N> y){ return new FunctionExpressionImpl(this.metamodel, (Class<N>)BasicTypeHelperImpl.getInstance().extendedBinaryNumericPromotion(x.getClass(), y.getJavaType()), ExpressionMath.add(new ConstantExpression(x, ((InternalSelection)y).getCurrentNode()),((InternalSelection)y).getCurrentNode()), buildList(internalLiteral(x),y), "sum"); }
/** * {@inheritDoc} */ @Override public void visit(EntityTypeLiteral expression) { ClassDescriptor descriptor = queryContext.getDescriptor(expression.getEntityTypeName()); type[0] = descriptor.getJavaClass(); queryExpression = new ConstantExpression(type[0], queryContext.getBaseExpression()); }
/** * {@inheritDoc} */ @Override public void visit(IdentificationVariable expression) { ClassDescriptor descriptor = queryContext.getDescriptor(expression.getVariableName()); queryExpression = queryContext.getBaseExpression(); queryExpression = new ConstantExpression(descriptor.getJavaClass(), queryExpression); }
/** * {@inheritDoc} */ @Override public void visit(IdentificationVariable expression) { ClassDescriptor descriptor = queryContext.getDescriptor(expression.getVariableName()); queryExpression = queryContext.getBaseExpression(); queryExpression = new ConstantExpression(descriptor.getJavaClass(), queryExpression); }
/** * {@inheritDoc} */ @Override public void visit(EntityTypeLiteral expression) { ClassDescriptor descriptor = queryContext.getDescriptor(expression.getEntityTypeName()); type[0] = descriptor.getJavaClass(); queryExpression = new ConstantExpression(type[0], queryContext.getBaseExpression()); }