org.hibernate.ejb.criteria.expression
Class BinaryArithmeticOperation<N extends java.lang.Number>

java.lang.Object
  extended by org.hibernate.ejb.criteria.AbstractNode
      extended by org.hibernate.ejb.criteria.expression.AbstractTupleElement<X>
          extended by org.hibernate.ejb.criteria.expression.SelectionImpl<T>
              extended by org.hibernate.ejb.criteria.expression.ExpressionImpl<N>
                  extended by org.hibernate.ejb.criteria.expression.BinaryArithmeticOperation<N>
All Implemented Interfaces:
java.io.Serializable, javax.persistence.criteria.Expression<N>, javax.persistence.criteria.Selection<N>, javax.persistence.TupleElement<N>, BinaryOperatorExpression<N>, ExpressionImplementor<N>, ParameterContainer, Renderable, SelectionImplementor<N>, TupleElementImplementor<N>

public class BinaryArithmeticOperation<N extends java.lang.Number>
extends ExpressionImpl<N>
implements BinaryOperatorExpression<N>, java.io.Serializable

Models standard arithmetc operations with two operands.

Author:
Steve Ebersole
See Also:
Serialized Form

Nested Class Summary
static class BinaryArithmeticOperation.Operation
           
 
Nested classes/interfaces inherited from interface org.hibernate.ejb.criteria.ParameterContainer
ParameterContainer.Helper
 
Constructor Summary
BinaryArithmeticOperation(CriteriaBuilderImpl criteriaBuilder, java.lang.Class<N> resultType, BinaryArithmeticOperation.Operation operator, javax.persistence.criteria.Expression<? extends N> lhs, javax.persistence.criteria.Expression<? extends N> rhs)
          Creates an arithmethic operation based on 2 expressions.
BinaryArithmeticOperation(CriteriaBuilderImpl criteriaBuilder, java.lang.Class<N> javaType, BinaryArithmeticOperation.Operation operator, javax.persistence.criteria.Expression<? extends N> lhs, N rhs)
          Creates an arithmethic operation based on an expression and a literal.
BinaryArithmeticOperation(CriteriaBuilderImpl criteriaBuilder, java.lang.Class<N> javaType, BinaryArithmeticOperation.Operation operator, N lhs, javax.persistence.criteria.Expression<? extends N> rhs)
          Creates an arithmetic operation based on an expression and a literal.
 
Method Summary
static java.lang.Class<? extends java.lang.Number> determineResultType(java.lang.Class<? extends java.lang.Number> argument1Type, java.lang.Class<? extends java.lang.Number> argument2Type)
           
static java.lang.Class<? extends java.lang.Number> determineResultType(java.lang.Class<? extends java.lang.Number> argument1Type, java.lang.Class<? extends java.lang.Number> argument2Type, boolean isQuotientOperation)
           
static java.lang.Class<? extends java.lang.Number> determineReturnType(java.lang.Class<? extends java.lang.Number> defaultType, javax.persistence.criteria.Expression<? extends java.lang.Number> expression)
          Helper for determining the appropriate operation return type based on one of the operands as an expression.
static java.lang.Class<? extends java.lang.Number> determineReturnType(java.lang.Class<? extends java.lang.Number> defaultType, java.lang.Number numberLiteral)
          Helper for determining the appropriate operation return type based on one of the operands as a literal.
 javax.persistence.criteria.Expression<? extends N> getLeftHandOperand()
          Get the left-hand operand.
 BinaryArithmeticOperation.Operation getOperator()
           
 javax.persistence.criteria.Expression<? extends N> getRightHandOperand()
          Get the right-hand operand.
 void registerParameters(ParameterRegistry registry)
          Register any parameters contained within this query component with the given registry.
 java.lang.String render(CriteriaQueryCompiler.RenderingContext renderingContext)
           
 java.lang.String renderProjection(CriteriaQueryCompiler.RenderingContext renderingContext)
           
 
Methods inherited from class org.hibernate.ejb.criteria.expression.ExpressionImpl
as, asBigDecimal, asBigInteger, asDouble, asFloat, asInteger, asLong, asString, in, in, in, in, isNotNull, isNull
 
Methods inherited from class org.hibernate.ejb.criteria.expression.SelectionImpl
alias, getCompoundSelectionItems, getValueHandlers, isCompoundSelection
 
Methods inherited from class org.hibernate.ejb.criteria.expression.AbstractTupleElement
forceConversion, getAlias, getJavaType, getValueHandler, resetJavaType, setAlias
 
Methods inherited from class org.hibernate.ejb.criteria.AbstractNode
criteriaBuilder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.persistence.criteria.Expression
as, in, in, in, in, isNotNull, isNull
 
Methods inherited from interface javax.persistence.criteria.Selection
alias, getCompoundSelectionItems, isCompoundSelection
 
Methods inherited from interface javax.persistence.TupleElement
getAlias, getJavaType
 
Methods inherited from interface org.hibernate.ejb.criteria.SelectionImplementor
getValueHandlers
 
Methods inherited from interface org.hibernate.ejb.criteria.TupleElementImplementor
getValueHandler
 

Constructor Detail

BinaryArithmeticOperation

public BinaryArithmeticOperation(CriteriaBuilderImpl criteriaBuilder,
                                 java.lang.Class<N> resultType,
                                 BinaryArithmeticOperation.Operation operator,
                                 javax.persistence.criteria.Expression<? extends N> lhs,
                                 javax.persistence.criteria.Expression<? extends N> rhs)
Creates an arithmethic operation based on 2 expressions.

Parameters:
criteriaBuilder - The builder for query components.
resultType - The operation result type
operator - The operator (type of operation).
lhs - The left-hand operand.
rhs - The right-hand operand

BinaryArithmeticOperation

public BinaryArithmeticOperation(CriteriaBuilderImpl criteriaBuilder,
                                 java.lang.Class<N> javaType,
                                 BinaryArithmeticOperation.Operation operator,
                                 javax.persistence.criteria.Expression<? extends N> lhs,
                                 N rhs)
Creates an arithmethic operation based on an expression and a literal.

Parameters:
criteriaBuilder - The builder for query components.
javaType - The operation result type
operator - The operator (type of operation).
lhs - The left-hand operand
rhs - The right-hand operand (the literal)

BinaryArithmeticOperation

public BinaryArithmeticOperation(CriteriaBuilderImpl criteriaBuilder,
                                 java.lang.Class<N> javaType,
                                 BinaryArithmeticOperation.Operation operator,
                                 N lhs,
                                 javax.persistence.criteria.Expression<? extends N> rhs)
Creates an arithmetic operation based on an expression and a literal.

Parameters:
criteriaBuilder - The builder for query components.
javaType - The operation result type
operator - The operator (type of operation).
lhs - The left-hand operand (the literal)
rhs - The right-hand operand
Method Detail

determineResultType

public static java.lang.Class<? extends java.lang.Number> determineResultType(java.lang.Class<? extends java.lang.Number> argument1Type,
                                                                              java.lang.Class<? extends java.lang.Number> argument2Type)

determineResultType

public static java.lang.Class<? extends java.lang.Number> determineResultType(java.lang.Class<? extends java.lang.Number> argument1Type,
                                                                              java.lang.Class<? extends java.lang.Number> argument2Type,
                                                                              boolean isQuotientOperation)

determineReturnType

public static java.lang.Class<? extends java.lang.Number> determineReturnType(java.lang.Class<? extends java.lang.Number> defaultType,
                                                                              javax.persistence.criteria.Expression<? extends java.lang.Number> expression)
Helper for determining the appropriate operation return type based on one of the operands as an expression.

Parameters:
defaultType - The default return type to use if we cannot determine the java type of 'expression' operand.
expression - The operand.
Returns:
The appropriate return type.

determineReturnType

public static java.lang.Class<? extends java.lang.Number> determineReturnType(java.lang.Class<? extends java.lang.Number> defaultType,
                                                                              java.lang.Number numberLiteral)
Helper for determining the appropriate operation return type based on one of the operands as a literal.

Parameters:
defaultType - The default return type to use if we cannot determine the java type of 'numberLiteral' operand.
numberLiteral - The operand.
Returns:
The appropriate return type.

getOperator

public BinaryArithmeticOperation.Operation getOperator()

getRightHandOperand

public javax.persistence.criteria.Expression<? extends N> getRightHandOperand()
Get the right-hand operand.

Specified by:
getRightHandOperand in interface BinaryOperatorExpression<N extends java.lang.Number>
Returns:
The right-hand operand.

getLeftHandOperand

public javax.persistence.criteria.Expression<? extends N> getLeftHandOperand()
Get the left-hand operand.

Specified by:
getLeftHandOperand in interface BinaryOperatorExpression<N extends java.lang.Number>
Returns:
The left-hand operand.

registerParameters

public void registerParameters(ParameterRegistry registry)
Register any parameters contained within this query component with the given registry.

Specified by:
registerParameters in interface ParameterContainer
Parameters:
registry - The parameter registry with which to register.

render

public java.lang.String render(CriteriaQueryCompiler.RenderingContext renderingContext)
Specified by:
render in interface Renderable

renderProjection

public java.lang.String renderProjection(CriteriaQueryCompiler.RenderingContext renderingContext)
Specified by:
renderProjection in interface Renderable


Copyright © 2011. All Rights Reserved.