protected ComparisonBuilder comparisonBuilder( DynamicOperand right ) { DynamicOperand leftOperand = null; // If the left operand is an arithmetic operand, then we need to check the operator precedence ... if (left instanceof ArithmeticOperand) { ArithmeticOperand leftArith = (ArithmeticOperand)left; ArithmeticOperator operator = leftArith.operator(); if (this.operator.precedes(operator)) { // Need to do create an operand with leftArith.right and right DynamicOperand inner = new ArithmeticOperand(leftArith.getRight(), this.operator, right); leftOperand = new ArithmeticOperand(leftArith.getLeft(), operator, inner); } else { // the left preceds this, so we can add the new operand on top ... leftOperand = new ArithmeticOperand(leftArith, operator, right); } } else { // The left isn't an arith ... leftOperand = new ArithmeticOperand(left, operator, right); } return new ComparisonBuilder(comparisonBuilder.constraintBuilder, leftOperand); } }
@Override public boolean equals( Object obj ) { if (obj == this) return true; if (obj instanceof ArithmeticOperand) { ArithmeticOperand that = (ArithmeticOperand)obj; return this.operator() == that.operator() && this.getLeft().equals(that.getLeft()) && this.getRight().equals(that.getRight()); } return false; }
protected ArithmeticOperand arithmeticOperand( DynamicOperand leftOperand, ArithmeticOperator operator, DynamicOperand rightOperand ) { return new ArithmeticOperand(leftOperand, operator, rightOperand); }
@Override public String getOperator() { switch (operator()) { case ADD: return QueryObjectModelConstants.JCR_ARITHMETIC_OPERATOR_ADD; case DIVIDE: return QueryObjectModelConstants.JCR_ARITHMETIC_OPERATOR_DIVIDE; case MULTIPLY: return QueryObjectModelConstants.JCR_ARITHMETIC_OPERATOR_MULTIPLY; case SUBTRACT: return QueryObjectModelConstants.JCR_ARITHMETIC_OPERATOR_SUBTRACT; } assert false; return null; }
@Override public boolean equals( Object obj ) { if (obj == this) return true; if (obj instanceof ArithmeticOperand) { ArithmeticOperand that = (ArithmeticOperand)obj; return this.operator() == that.operator() && this.getLeft().equals(that.getLeft()) && this.getRight().equals(that.getRight()); } return false; }
protected ArithmeticOperand arithmeticOperand( DynamicOperand leftOperand, ArithmeticOperator operator, DynamicOperand rightOperand ) { return new ArithmeticOperand(leftOperand, operator, rightOperand); }
@Override public String getOperator() { switch (operator()) { case ADD: return QueryObjectModelConstants.JCR_ARITHMETIC_OPERATOR_ADD; case DIVIDE: return QueryObjectModelConstants.JCR_ARITHMETIC_OPERATOR_DIVIDE; case MULTIPLY: return QueryObjectModelConstants.JCR_ARITHMETIC_OPERATOR_MULTIPLY; case SUBTRACT: return QueryObjectModelConstants.JCR_ARITHMETIC_OPERATOR_SUBTRACT; } assert false; return null; }
protected ComparisonBuilder comparisonBuilder( DynamicOperand right ) { DynamicOperand leftOperand = null; // If the left operand is an arithmetic operand, then we need to check the operator precedence ... if (left instanceof ArithmeticOperand) { ArithmeticOperand leftArith = (ArithmeticOperand)left; ArithmeticOperator operator = leftArith.operator(); if (this.operator.precedes(operator)) { // Need to do create an operand with leftArith.right and right DynamicOperand inner = new ArithmeticOperand(leftArith.getRight(), this.operator, right); leftOperand = new ArithmeticOperand(leftArith.getLeft(), operator, inner); } else { // the left preceds this, so we can add the new operand on top ... leftOperand = new ArithmeticOperand(leftArith, operator, right); } } else { // The left isn't an arith ... leftOperand = new ArithmeticOperand(left, operator, right); } return new ComparisonBuilder(comparisonBuilder.constraintBuilder, leftOperand); } }
public ArithmeticOperand arithmeticOperand( javax.jcr.query.qom.DynamicOperand left, ArithmeticOperator operator, javax.jcr.query.qom.DynamicOperand right ) { DynamicOperand leftOperand = CheckArg.getInstanceOf(left, DynamicOperand.class, "left"); DynamicOperand rightOperand = CheckArg.getInstanceOf(left, DynamicOperand.class, "left"); return new ArithmeticOperand(leftOperand, operator, rightOperand); }
if (operand instanceof ArithmeticOperand) { ArithmeticOperand arith = (ArithmeticOperand)operand; DynamicOperand newLeft = replaceAliasesWithProperties(context, arith.getLeft(), propertyByAlias); DynamicOperand newRight = replaceAliasesWithProperties(context, arith.getRight(), propertyByAlias); if (newLeft == arith.getLeft() && newRight == arith.getRight()) return arith; return new ArithmeticOperand(newLeft, arith.operator(), newRight);
public ArithmeticOperand arithmeticOperand( javax.jcr.query.qom.DynamicOperand left, ArithmeticOperator operator, javax.jcr.query.qom.DynamicOperand right ) { DynamicOperand leftOperand = CheckArg.getInstanceOf(left, DynamicOperand.class, "left"); DynamicOperand rightOperand = CheckArg.getInstanceOf(left, DynamicOperand.class, "left"); return new ArithmeticOperand(leftOperand, operator, rightOperand); }
if (operand instanceof ArithmeticOperand) { ArithmeticOperand arith = (ArithmeticOperand)operand; DynamicOperand newLeft = replaceAliasesWithProperties(context, arith.getLeft(), propertyByAlias); DynamicOperand newRight = replaceAliasesWithProperties(context, arith.getRight(), propertyByAlias); if (newLeft == arith.getLeft() && newRight == arith.getRight()) return arith; return new ArithmeticOperand(newLeft, arith.operator(), newRight);
final ExtractFromRow leftOp = createExtractFromRow(arith.getLeft(), context, columns, sources, defaultType, false, false); final ExtractFromRow rightOp = createExtractFromRow(arith.getRight(), context, columns, sources, defaultType, false, false); if (typeSystem.getDoubleFactory().getTypeName().equals(commonType)) { final TypeFactory<Double> commonTypeFactory = typeSystem.getDoubleFactory(); switch (arith.operator()) { case ADD: return new ExtractFromRow() { switch (arith.operator()) { case ADD: return new ExtractFromRow() {