Java Code Examples for org.springframework.expression.spel.CodeFlow#toDescriptorFromObject()
The following examples show how to use
org.springframework.expression.spel.CodeFlow#toDescriptorFromObject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpEQ.java From spring-analysis-note with MIT License | 5 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); return BooleanTypedValue.forValue(equalityCheck(state.getEvaluationContext(), left, right)); }
Example 2
Source File: OpNE.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); return BooleanTypedValue.forValue(!equalityCheck(state, left, right)); }
Example 3
Source File: OpEQ.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); return BooleanTypedValue.forValue(equalityCheck(state, left, right)); }
Example 4
Source File: OpNE.java From java-technology-stack with MIT License | 5 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object leftValue = getLeftOperand().getValueInternal(state).getValue(); Object rightValue = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(leftValue); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(rightValue); return BooleanTypedValue.forValue(!equalityCheck(state.getEvaluationContext(), leftValue, rightValue)); }
Example 5
Source File: OpEQ.java From java-technology-stack with MIT License | 5 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); return BooleanTypedValue.forValue(equalityCheck(state.getEvaluationContext(), left, right)); }
Example 6
Source File: OpEQ.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); return BooleanTypedValue.forValue( equalityCheck(state.getEvaluationContext(), left, right)); }
Example 7
Source File: OpNE.java From spring-analysis-note with MIT License | 5 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object leftValue = getLeftOperand().getValueInternal(state).getValue(); Object rightValue = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(leftValue); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(rightValue); return BooleanTypedValue.forValue(!equalityCheck(state.getEvaluationContext(), leftValue, rightValue)); }
Example 8
Source File: OpNE.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); return BooleanTypedValue.forValue( !equalityCheck(state.getEvaluationContext(), left, right)); }
Example 9
Source File: OpLE.java From java-technology-stack with MIT License | 4 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); if (left instanceof Number && right instanceof Number) { Number leftNumber = (Number) left; Number rightNumber = (Number) right; if (leftNumber instanceof BigDecimal || rightNumber instanceof BigDecimal) { BigDecimal leftBigDecimal = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class); BigDecimal rightBigDecimal = NumberUtils.convertNumberToTargetClass(rightNumber, BigDecimal.class); return BooleanTypedValue.forValue(leftBigDecimal.compareTo(rightBigDecimal) <= 0); } else if (leftNumber instanceof Double || rightNumber instanceof Double) { return BooleanTypedValue.forValue(leftNumber.doubleValue() <= rightNumber.doubleValue()); } else if (leftNumber instanceof Float || rightNumber instanceof Float) { return BooleanTypedValue.forValue(leftNumber.floatValue() <= rightNumber.floatValue()); } else if (leftNumber instanceof BigInteger || rightNumber instanceof BigInteger) { BigInteger leftBigInteger = NumberUtils.convertNumberToTargetClass(leftNumber, BigInteger.class); BigInteger rightBigInteger = NumberUtils.convertNumberToTargetClass(rightNumber, BigInteger.class); return BooleanTypedValue.forValue(leftBigInteger.compareTo(rightBigInteger) <= 0); } else if (leftNumber instanceof Long || rightNumber instanceof Long) { return BooleanTypedValue.forValue(leftNumber.longValue() <= rightNumber.longValue()); } else if (leftNumber instanceof Integer || rightNumber instanceof Integer) { return BooleanTypedValue.forValue(leftNumber.intValue() <= rightNumber.intValue()); } else if (leftNumber instanceof Short || rightNumber instanceof Short) { return BooleanTypedValue.forValue(leftNumber.shortValue() <= rightNumber.shortValue()); } else if (leftNumber instanceof Byte || rightNumber instanceof Byte) { return BooleanTypedValue.forValue(leftNumber.byteValue() <= rightNumber.byteValue()); } else { // Unknown Number subtypes -> best guess is double comparison return BooleanTypedValue.forValue(leftNumber.doubleValue() <= rightNumber.doubleValue()); } } return BooleanTypedValue.forValue(state.getTypeComparator().compare(left, right) <= 0); }
Example 10
Source File: OpGE.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); if (left instanceof Number && right instanceof Number) { Number leftNumber = (Number) left; Number rightNumber = (Number) right; if (leftNumber instanceof BigDecimal || rightNumber instanceof BigDecimal) { BigDecimal leftBigDecimal = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class); BigDecimal rightBigDecimal = NumberUtils.convertNumberToTargetClass(rightNumber, BigDecimal.class); return BooleanTypedValue.forValue(leftBigDecimal.compareTo(rightBigDecimal) >= 0); } else if (leftNumber instanceof Double || rightNumber instanceof Double) { return BooleanTypedValue.forValue(leftNumber.doubleValue() >= rightNumber.doubleValue()); } else if (leftNumber instanceof Float || rightNumber instanceof Float) { return BooleanTypedValue.forValue(leftNumber.floatValue() >= rightNumber.floatValue()); } else if (leftNumber instanceof BigInteger || rightNumber instanceof BigInteger) { BigInteger leftBigInteger = NumberUtils.convertNumberToTargetClass(leftNumber, BigInteger.class); BigInteger rightBigInteger = NumberUtils.convertNumberToTargetClass(rightNumber, BigInteger.class); return BooleanTypedValue.forValue(leftBigInteger.compareTo(rightBigInteger) >= 0); } else if (leftNumber instanceof Long || rightNumber instanceof Long) { return BooleanTypedValue.forValue(leftNumber.longValue() >= rightNumber.longValue()); } else if (leftNumber instanceof Integer || rightNumber instanceof Integer) { return BooleanTypedValue.forValue(leftNumber.intValue() >= rightNumber.intValue()); } else if (leftNumber instanceof Short || rightNumber instanceof Short) { return BooleanTypedValue.forValue(leftNumber.shortValue() >= rightNumber.shortValue()); } else if (leftNumber instanceof Byte || rightNumber instanceof Byte) { return BooleanTypedValue.forValue(leftNumber.byteValue() >= rightNumber.byteValue()); } else { // Unknown Number subtypes -> best guess is double comparison return BooleanTypedValue.forValue(leftNumber.doubleValue() >= rightNumber.doubleValue()); } } return BooleanTypedValue.forValue(state.getTypeComparator().compare(left, right) >= 0); }
Example 11
Source File: OpGT.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); if (left instanceof Number && right instanceof Number) { Number leftNumber = (Number) left; Number rightNumber = (Number) right; if (leftNumber instanceof BigDecimal || rightNumber instanceof BigDecimal) { BigDecimal leftBigDecimal = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class); BigDecimal rightBigDecimal = NumberUtils.convertNumberToTargetClass(rightNumber, BigDecimal.class); return BooleanTypedValue.forValue(leftBigDecimal.compareTo(rightBigDecimal) > 0); } else if (leftNumber instanceof Double || rightNumber instanceof Double) { return BooleanTypedValue.forValue(leftNumber.doubleValue() > rightNumber.doubleValue()); } else if (leftNumber instanceof Float || rightNumber instanceof Float) { return BooleanTypedValue.forValue(leftNumber.floatValue() > rightNumber.floatValue()); } else if (leftNumber instanceof BigInteger || rightNumber instanceof BigInteger) { BigInteger leftBigInteger = NumberUtils.convertNumberToTargetClass(leftNumber, BigInteger.class); BigInteger rightBigInteger = NumberUtils.convertNumberToTargetClass(rightNumber, BigInteger.class); return BooleanTypedValue.forValue(leftBigInteger.compareTo(rightBigInteger) > 0); } else if (leftNumber instanceof Long || rightNumber instanceof Long) { return BooleanTypedValue.forValue(leftNumber.longValue() > rightNumber.longValue()); } else if (leftNumber instanceof Integer || rightNumber instanceof Integer) { return BooleanTypedValue.forValue(leftNumber.intValue() > rightNumber.intValue()); } else if (leftNumber instanceof Short || rightNumber instanceof Short) { return BooleanTypedValue.forValue(leftNumber.shortValue() > rightNumber.shortValue()); } else if (leftNumber instanceof Byte || rightNumber instanceof Byte) { return BooleanTypedValue.forValue(leftNumber.byteValue() > rightNumber.byteValue()); } else { // Unknown Number subtypes -> best guess is double comparison return BooleanTypedValue.forValue(leftNumber.doubleValue() > rightNumber.doubleValue()); } } if (left instanceof CharSequence && right instanceof CharSequence) { left = left.toString(); right = right.toString(); } return BooleanTypedValue.forValue(state.getTypeComparator().compare(left, right) > 0); }
Example 12
Source File: OpLT.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); if (left instanceof Number && right instanceof Number) { Number leftNumber = (Number) left; Number rightNumber = (Number) right; if (leftNumber instanceof BigDecimal || rightNumber instanceof BigDecimal) { BigDecimal leftBigDecimal = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class); BigDecimal rightBigDecimal = NumberUtils.convertNumberToTargetClass(rightNumber, BigDecimal.class); return BooleanTypedValue.forValue(leftBigDecimal.compareTo(rightBigDecimal) < 0); } else if (leftNumber instanceof Double || rightNumber instanceof Double) { return BooleanTypedValue.forValue(leftNumber.doubleValue() < rightNumber.doubleValue()); } else if (leftNumber instanceof Float || rightNumber instanceof Float) { return BooleanTypedValue.forValue(leftNumber.floatValue() < rightNumber.floatValue()); } else if (leftNumber instanceof BigInteger || rightNumber instanceof BigInteger) { BigInteger leftBigInteger = NumberUtils.convertNumberToTargetClass(leftNumber, BigInteger.class); BigInteger rightBigInteger = NumberUtils.convertNumberToTargetClass(rightNumber, BigInteger.class); return BooleanTypedValue.forValue(leftBigInteger.compareTo(rightBigInteger) < 0); } else if (leftNumber instanceof Long || rightNumber instanceof Long) { return BooleanTypedValue.forValue(leftNumber.longValue() < rightNumber.longValue()); } else if (leftNumber instanceof Integer || rightNumber instanceof Integer) { return BooleanTypedValue.forValue(leftNumber.intValue() < rightNumber.intValue()); } else if (leftNumber instanceof Short || rightNumber instanceof Short) { return BooleanTypedValue.forValue(leftNumber.shortValue() < rightNumber.shortValue()); } else if (leftNumber instanceof Byte || rightNumber instanceof Byte) { return BooleanTypedValue.forValue(leftNumber.byteValue() < rightNumber.byteValue()); } else { // Unknown Number subtypes -> best guess is double comparison return BooleanTypedValue.forValue(leftNumber.doubleValue() < rightNumber.doubleValue()); } } if (left instanceof CharSequence && right instanceof CharSequence) { left = left.toString(); right = right.toString(); } return BooleanTypedValue.forValue(state.getTypeComparator().compare(left, right) < 0); }
Example 13
Source File: OpGT.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); if (left instanceof Number && right instanceof Number) { Number leftNumber = (Number) left; Number rightNumber = (Number) right; if (leftNumber instanceof BigDecimal || rightNumber instanceof BigDecimal) { BigDecimal leftBigDecimal = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class); BigDecimal rightBigDecimal = NumberUtils.convertNumberToTargetClass(rightNumber, BigDecimal.class); return BooleanTypedValue.forValue(leftBigDecimal.compareTo(rightBigDecimal) > 0); } else if (leftNumber instanceof Double || rightNumber instanceof Double) { return BooleanTypedValue.forValue(leftNumber.doubleValue() > rightNumber.doubleValue()); } else if (leftNumber instanceof Float || rightNumber instanceof Float) { return BooleanTypedValue.forValue(leftNumber.floatValue() > rightNumber.floatValue()); } else if (leftNumber instanceof BigInteger || rightNumber instanceof BigInteger) { BigInteger leftBigInteger = NumberUtils.convertNumberToTargetClass(leftNumber, BigInteger.class); BigInteger rightBigInteger = NumberUtils.convertNumberToTargetClass(rightNumber, BigInteger.class); return BooleanTypedValue.forValue(leftBigInteger.compareTo(rightBigInteger) > 0); } else if (leftNumber instanceof Long || rightNumber instanceof Long) { return BooleanTypedValue.forValue(leftNumber.longValue() > rightNumber.longValue()); } else if (leftNumber instanceof Integer || rightNumber instanceof Integer) { return BooleanTypedValue.forValue(leftNumber.intValue() > rightNumber.intValue()); } else if (leftNumber instanceof Short || rightNumber instanceof Short) { return BooleanTypedValue.forValue(leftNumber.shortValue() > rightNumber.shortValue()); } else if (leftNumber instanceof Byte || rightNumber instanceof Byte) { return BooleanTypedValue.forValue(leftNumber.byteValue() > rightNumber.byteValue()); } else { // Unknown Number subtypes -> best guess is double comparison return BooleanTypedValue.forValue(leftNumber.doubleValue() > rightNumber.doubleValue()); } } if (left instanceof CharSequence && right instanceof CharSequence) { left = left.toString(); right = right.toString(); } return BooleanTypedValue.forValue(state.getTypeComparator().compare(left, right) > 0); }
Example 14
Source File: OpGT.java From java-technology-stack with MIT License | 4 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); if (left instanceof Number && right instanceof Number) { Number leftNumber = (Number) left; Number rightNumber = (Number) right; if (leftNumber instanceof BigDecimal || rightNumber instanceof BigDecimal) { BigDecimal leftBigDecimal = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class); BigDecimal rightBigDecimal = NumberUtils.convertNumberToTargetClass(rightNumber, BigDecimal.class); return BooleanTypedValue.forValue(leftBigDecimal.compareTo(rightBigDecimal) > 0); } else if (leftNumber instanceof Double || rightNumber instanceof Double) { return BooleanTypedValue.forValue(leftNumber.doubleValue() > rightNumber.doubleValue()); } else if (leftNumber instanceof Float || rightNumber instanceof Float) { return BooleanTypedValue.forValue(leftNumber.floatValue() > rightNumber.floatValue()); } else if (leftNumber instanceof BigInteger || rightNumber instanceof BigInteger) { BigInteger leftBigInteger = NumberUtils.convertNumberToTargetClass(leftNumber, BigInteger.class); BigInteger rightBigInteger = NumberUtils.convertNumberToTargetClass(rightNumber, BigInteger.class); return BooleanTypedValue.forValue(leftBigInteger.compareTo(rightBigInteger) > 0); } else if (leftNumber instanceof Long || rightNumber instanceof Long) { return BooleanTypedValue.forValue(leftNumber.longValue() > rightNumber.longValue()); } else if (leftNumber instanceof Integer || rightNumber instanceof Integer) { return BooleanTypedValue.forValue(leftNumber.intValue() > rightNumber.intValue()); } else if (leftNumber instanceof Short || rightNumber instanceof Short) { return BooleanTypedValue.forValue(leftNumber.shortValue() > rightNumber.shortValue()); } else if (leftNumber instanceof Byte || rightNumber instanceof Byte) { return BooleanTypedValue.forValue(leftNumber.byteValue() > rightNumber.byteValue()); } else { // Unknown Number subtypes -> best guess is double comparison return BooleanTypedValue.forValue(leftNumber.doubleValue() > rightNumber.doubleValue()); } } if (left instanceof CharSequence && right instanceof CharSequence) { left = left.toString(); right = right.toString(); } return BooleanTypedValue.forValue(state.getTypeComparator().compare(left, right) > 0); }
Example 15
Source File: OpLT.java From java-technology-stack with MIT License | 4 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); if (left instanceof Number && right instanceof Number) { Number leftNumber = (Number) left; Number rightNumber = (Number) right; if (leftNumber instanceof BigDecimal || rightNumber instanceof BigDecimal) { BigDecimal leftBigDecimal = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class); BigDecimal rightBigDecimal = NumberUtils.convertNumberToTargetClass(rightNumber, BigDecimal.class); return BooleanTypedValue.forValue(leftBigDecimal.compareTo(rightBigDecimal) < 0); } else if (leftNumber instanceof Double || rightNumber instanceof Double) { return BooleanTypedValue.forValue(leftNumber.doubleValue() < rightNumber.doubleValue()); } else if (leftNumber instanceof Float || rightNumber instanceof Float) { return BooleanTypedValue.forValue(leftNumber.floatValue() < rightNumber.floatValue()); } else if (leftNumber instanceof BigInteger || rightNumber instanceof BigInteger) { BigInteger leftBigInteger = NumberUtils.convertNumberToTargetClass(leftNumber, BigInteger.class); BigInteger rightBigInteger = NumberUtils.convertNumberToTargetClass(rightNumber, BigInteger.class); return BooleanTypedValue.forValue(leftBigInteger.compareTo(rightBigInteger) < 0); } else if (leftNumber instanceof Long || rightNumber instanceof Long) { return BooleanTypedValue.forValue(leftNumber.longValue() < rightNumber.longValue()); } else if (leftNumber instanceof Integer || rightNumber instanceof Integer) { return BooleanTypedValue.forValue(leftNumber.intValue() < rightNumber.intValue()); } else if (leftNumber instanceof Short || rightNumber instanceof Short) { return BooleanTypedValue.forValue(leftNumber.shortValue() < rightNumber.shortValue()); } else if (leftNumber instanceof Byte || rightNumber instanceof Byte) { return BooleanTypedValue.forValue(leftNumber.byteValue() < rightNumber.byteValue()); } else { // Unknown Number subtypes -> best guess is double comparison return BooleanTypedValue.forValue(leftNumber.doubleValue() < rightNumber.doubleValue()); } } if (left instanceof CharSequence && right instanceof CharSequence) { left = left.toString(); right = right.toString(); } return BooleanTypedValue.forValue(state.getTypeComparator().compare(left, right) < 0); }
Example 16
Source File: OpLT.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); if (left instanceof Number && right instanceof Number) { Number leftNumber = (Number) left; Number rightNumber = (Number) right; if (leftNumber instanceof BigDecimal || rightNumber instanceof BigDecimal) { BigDecimal leftBigDecimal = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class); BigDecimal rightBigDecimal = NumberUtils.convertNumberToTargetClass(rightNumber, BigDecimal.class); return BooleanTypedValue.forValue(leftBigDecimal.compareTo(rightBigDecimal) < 0); } else if (leftNumber instanceof Double || rightNumber instanceof Double) { return BooleanTypedValue.forValue(leftNumber.doubleValue() < rightNumber.doubleValue()); } else if (leftNumber instanceof Float || rightNumber instanceof Float) { return BooleanTypedValue.forValue(leftNumber.floatValue() < rightNumber.floatValue()); } else if (leftNumber instanceof BigInteger || rightNumber instanceof BigInteger) { BigInteger leftBigInteger = NumberUtils.convertNumberToTargetClass(leftNumber, BigInteger.class); BigInteger rightBigInteger = NumberUtils.convertNumberToTargetClass(rightNumber, BigInteger.class); return BooleanTypedValue.forValue(leftBigInteger.compareTo(rightBigInteger) < 0); } else if (leftNumber instanceof Long || rightNumber instanceof Long) { return BooleanTypedValue.forValue(leftNumber.longValue() < rightNumber.longValue()); } else if (leftNumber instanceof Integer || rightNumber instanceof Integer) { return BooleanTypedValue.forValue(leftNumber.intValue() < rightNumber.intValue()); } else if (leftNumber instanceof Short || rightNumber instanceof Short) { return BooleanTypedValue.forValue(leftNumber.shortValue() < rightNumber.shortValue()); } else if (leftNumber instanceof Byte || rightNumber instanceof Byte) { return BooleanTypedValue.forValue(leftNumber.byteValue() < rightNumber.byteValue()); } else { // Unknown Number subtypes -> best guess is double comparison return BooleanTypedValue.forValue(leftNumber.doubleValue() < rightNumber.doubleValue()); } } if (left instanceof CharSequence && right instanceof CharSequence) { left = left.toString(); right = right.toString(); } return BooleanTypedValue.forValue(state.getTypeComparator().compare(left, right) < 0); }
Example 17
Source File: OpGT.java From spring-analysis-note with MIT License | 4 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); if (left instanceof Number && right instanceof Number) { Number leftNumber = (Number) left; Number rightNumber = (Number) right; if (leftNumber instanceof BigDecimal || rightNumber instanceof BigDecimal) { BigDecimal leftBigDecimal = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class); BigDecimal rightBigDecimal = NumberUtils.convertNumberToTargetClass(rightNumber, BigDecimal.class); return BooleanTypedValue.forValue(leftBigDecimal.compareTo(rightBigDecimal) > 0); } else if (leftNumber instanceof Double || rightNumber instanceof Double) { return BooleanTypedValue.forValue(leftNumber.doubleValue() > rightNumber.doubleValue()); } else if (leftNumber instanceof Float || rightNumber instanceof Float) { return BooleanTypedValue.forValue(leftNumber.floatValue() > rightNumber.floatValue()); } else if (leftNumber instanceof BigInteger || rightNumber instanceof BigInteger) { BigInteger leftBigInteger = NumberUtils.convertNumberToTargetClass(leftNumber, BigInteger.class); BigInteger rightBigInteger = NumberUtils.convertNumberToTargetClass(rightNumber, BigInteger.class); return BooleanTypedValue.forValue(leftBigInteger.compareTo(rightBigInteger) > 0); } else if (leftNumber instanceof Long || rightNumber instanceof Long) { return BooleanTypedValue.forValue(leftNumber.longValue() > rightNumber.longValue()); } else if (leftNumber instanceof Integer || rightNumber instanceof Integer) { return BooleanTypedValue.forValue(leftNumber.intValue() > rightNumber.intValue()); } else if (leftNumber instanceof Short || rightNumber instanceof Short) { return BooleanTypedValue.forValue(leftNumber.shortValue() > rightNumber.shortValue()); } else if (leftNumber instanceof Byte || rightNumber instanceof Byte) { return BooleanTypedValue.forValue(leftNumber.byteValue() > rightNumber.byteValue()); } else { // Unknown Number subtypes -> best guess is double comparison return BooleanTypedValue.forValue(leftNumber.doubleValue() > rightNumber.doubleValue()); } } if (left instanceof CharSequence && right instanceof CharSequence) { left = left.toString(); right = right.toString(); } return BooleanTypedValue.forValue(state.getTypeComparator().compare(left, right) > 0); }
Example 18
Source File: OpLE.java From spring-analysis-note with MIT License | 4 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); if (left instanceof Number && right instanceof Number) { Number leftNumber = (Number) left; Number rightNumber = (Number) right; if (leftNumber instanceof BigDecimal || rightNumber instanceof BigDecimal) { BigDecimal leftBigDecimal = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class); BigDecimal rightBigDecimal = NumberUtils.convertNumberToTargetClass(rightNumber, BigDecimal.class); return BooleanTypedValue.forValue(leftBigDecimal.compareTo(rightBigDecimal) <= 0); } else if (leftNumber instanceof Double || rightNumber instanceof Double) { return BooleanTypedValue.forValue(leftNumber.doubleValue() <= rightNumber.doubleValue()); } else if (leftNumber instanceof Float || rightNumber instanceof Float) { return BooleanTypedValue.forValue(leftNumber.floatValue() <= rightNumber.floatValue()); } else if (leftNumber instanceof BigInteger || rightNumber instanceof BigInteger) { BigInteger leftBigInteger = NumberUtils.convertNumberToTargetClass(leftNumber, BigInteger.class); BigInteger rightBigInteger = NumberUtils.convertNumberToTargetClass(rightNumber, BigInteger.class); return BooleanTypedValue.forValue(leftBigInteger.compareTo(rightBigInteger) <= 0); } else if (leftNumber instanceof Long || rightNumber instanceof Long) { return BooleanTypedValue.forValue(leftNumber.longValue() <= rightNumber.longValue()); } else if (leftNumber instanceof Integer || rightNumber instanceof Integer) { return BooleanTypedValue.forValue(leftNumber.intValue() <= rightNumber.intValue()); } else if (leftNumber instanceof Short || rightNumber instanceof Short) { return BooleanTypedValue.forValue(leftNumber.shortValue() <= rightNumber.shortValue()); } else if (leftNumber instanceof Byte || rightNumber instanceof Byte) { return BooleanTypedValue.forValue(leftNumber.byteValue() <= rightNumber.byteValue()); } else { // Unknown Number subtypes -> best guess is double comparison return BooleanTypedValue.forValue(leftNumber.doubleValue() <= rightNumber.doubleValue()); } } return BooleanTypedValue.forValue(state.getTypeComparator().compare(left, right) <= 0); }
Example 19
Source File: OpLT.java From spring-analysis-note with MIT License | 4 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); if (left instanceof Number && right instanceof Number) { Number leftNumber = (Number) left; Number rightNumber = (Number) right; if (leftNumber instanceof BigDecimal || rightNumber instanceof BigDecimal) { BigDecimal leftBigDecimal = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class); BigDecimal rightBigDecimal = NumberUtils.convertNumberToTargetClass(rightNumber, BigDecimal.class); return BooleanTypedValue.forValue(leftBigDecimal.compareTo(rightBigDecimal) < 0); } else if (leftNumber instanceof Double || rightNumber instanceof Double) { return BooleanTypedValue.forValue(leftNumber.doubleValue() < rightNumber.doubleValue()); } else if (leftNumber instanceof Float || rightNumber instanceof Float) { return BooleanTypedValue.forValue(leftNumber.floatValue() < rightNumber.floatValue()); } else if (leftNumber instanceof BigInteger || rightNumber instanceof BigInteger) { BigInteger leftBigInteger = NumberUtils.convertNumberToTargetClass(leftNumber, BigInteger.class); BigInteger rightBigInteger = NumberUtils.convertNumberToTargetClass(rightNumber, BigInteger.class); return BooleanTypedValue.forValue(leftBigInteger.compareTo(rightBigInteger) < 0); } else if (leftNumber instanceof Long || rightNumber instanceof Long) { return BooleanTypedValue.forValue(leftNumber.longValue() < rightNumber.longValue()); } else if (leftNumber instanceof Integer || rightNumber instanceof Integer) { return BooleanTypedValue.forValue(leftNumber.intValue() < rightNumber.intValue()); } else if (leftNumber instanceof Short || rightNumber instanceof Short) { return BooleanTypedValue.forValue(leftNumber.shortValue() < rightNumber.shortValue()); } else if (leftNumber instanceof Byte || rightNumber instanceof Byte) { return BooleanTypedValue.forValue(leftNumber.byteValue() < rightNumber.byteValue()); } else { // Unknown Number subtypes -> best guess is double comparison return BooleanTypedValue.forValue(leftNumber.doubleValue() < rightNumber.doubleValue()); } } if (left instanceof CharSequence && right instanceof CharSequence) { left = left.toString(); right = right.toString(); } return BooleanTypedValue.forValue(state.getTypeComparator().compare(left, right) < 0); }
Example 20
Source File: OpLE.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left); this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right); if (left instanceof Number && right instanceof Number) { Number leftNumber = (Number) left; Number rightNumber = (Number) right; if (leftNumber instanceof BigDecimal || rightNumber instanceof BigDecimal) { BigDecimal leftBigDecimal = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class); BigDecimal rightBigDecimal = NumberUtils.convertNumberToTargetClass(rightNumber, BigDecimal.class); return BooleanTypedValue.forValue(leftBigDecimal.compareTo(rightBigDecimal) <= 0); } else if (leftNumber instanceof Double || rightNumber instanceof Double) { return BooleanTypedValue.forValue(leftNumber.doubleValue() <= rightNumber.doubleValue()); } else if (leftNumber instanceof Float || rightNumber instanceof Float) { return BooleanTypedValue.forValue(leftNumber.floatValue() <= rightNumber.floatValue()); } else if (leftNumber instanceof BigInteger || rightNumber instanceof BigInteger) { BigInteger leftBigInteger = NumberUtils.convertNumberToTargetClass(leftNumber, BigInteger.class); BigInteger rightBigInteger = NumberUtils.convertNumberToTargetClass(rightNumber, BigInteger.class); return BooleanTypedValue.forValue(leftBigInteger.compareTo(rightBigInteger) <= 0); } else if (leftNumber instanceof Long || rightNumber instanceof Long) { return BooleanTypedValue.forValue(leftNumber.longValue() <= rightNumber.longValue()); } else if (leftNumber instanceof Integer || rightNumber instanceof Integer) { return BooleanTypedValue.forValue(leftNumber.intValue() <= rightNumber.intValue()); } else if (leftNumber instanceof Short || rightNumber instanceof Short) { return BooleanTypedValue.forValue(leftNumber.shortValue() <= rightNumber.shortValue()); } else if (leftNumber instanceof Byte || rightNumber instanceof Byte) { return BooleanTypedValue.forValue(leftNumber.byteValue() <= rightNumber.byteValue()); } else { // Unknown Number subtypes -> best guess is double comparison return BooleanTypedValue.forValue(leftNumber.doubleValue() <= rightNumber.doubleValue()); } } return BooleanTypedValue.forValue(state.getTypeComparator().compare(left, right) <= 0); }