Java Code Examples for org.springframework.expression.spel.SpelMessage#BETWEEN_RIGHT_OPERAND_MUST_BE_TWO_ELEMENT_LIST
The following examples show how to use
org.springframework.expression.spel.SpelMessage#BETWEEN_RIGHT_OPERAND_MUST_BE_TWO_ELEMENT_LIST .
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: OperatorBetween.java From spring-analysis-note with MIT License | 6 votes |
/** * Returns a boolean based on whether a value is in the range expressed. The first * operand is any value whilst the second is a list of two values - those two values * being the bounds allowed for the first operand (inclusive). * @param state the expression state * @return true if the left operand is in the range specified, false otherwise * @throws EvaluationException if there is a problem evaluating the expression */ @Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); if (!(right instanceof List) || ((List<?>) right).size() != 2) { throw new SpelEvaluationException(getRightOperand().getStartPosition(), SpelMessage.BETWEEN_RIGHT_OPERAND_MUST_BE_TWO_ELEMENT_LIST); } List<?> list = (List<?>) right; Object low = list.get(0); Object high = list.get(1); TypeComparator comp = state.getTypeComparator(); try { return BooleanTypedValue.forValue(comp.compare(left, low) >= 0 && comp.compare(left, high) <= 0); } catch (SpelEvaluationException ex) { ex.setPosition(getStartPosition()); throw ex; } }
Example 2
Source File: OperatorBetween.java From java-technology-stack with MIT License | 6 votes |
/** * Returns a boolean based on whether a value is in the range expressed. The first * operand is any value whilst the second is a list of two values - those two values * being the bounds allowed for the first operand (inclusive). * @param state the expression state * @return true if the left operand is in the range specified, false otherwise * @throws EvaluationException if there is a problem evaluating the expression */ @Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); if (!(right instanceof List) || ((List<?>) right).size() != 2) { throw new SpelEvaluationException(getRightOperand().getStartPosition(), SpelMessage.BETWEEN_RIGHT_OPERAND_MUST_BE_TWO_ELEMENT_LIST); } List<?> list = (List<?>) right; Object low = list.get(0); Object high = list.get(1); TypeComparator comp = state.getTypeComparator(); try { return BooleanTypedValue.forValue(comp.compare(left, low) >= 0 && comp.compare(left, high) <= 0); } catch (SpelEvaluationException ex) { ex.setPosition(getStartPosition()); throw ex; } }
Example 3
Source File: OperatorBetween.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Returns a boolean based on whether a value is in the range expressed. The first * operand is any value whilst the second is a list of two values - those two values * being the bounds allowed for the first operand (inclusive). * @param state the expression state * @return true if the left operand is in the range specified, false otherwise * @throws EvaluationException if there is a problem evaluating the expression */ @Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); if (!(right instanceof List) || ((List<?>) right).size() != 2) { throw new SpelEvaluationException(getRightOperand().getStartPosition(), SpelMessage.BETWEEN_RIGHT_OPERAND_MUST_BE_TWO_ELEMENT_LIST); } List<?> list = (List<?>) right; Object low = list.get(0); Object high = list.get(1); TypeComparator comp = state.getTypeComparator(); try { return BooleanTypedValue.forValue(comp.compare(left, low) >= 0 && comp.compare(left, high) <= 0); } catch (SpelEvaluationException ex) { ex.setPosition(getStartPosition()); throw ex; } }
Example 4
Source File: OperatorBetween.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Returns a boolean based on whether a value is in the range expressed. The first * operand is any value whilst the second is a list of two values - those two values * being the bounds allowed for the first operand (inclusive). * @param state the expression state * @return true if the left operand is in the range specified, false otherwise * @throws EvaluationException if there is a problem evaluating the expression */ @Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); if (!(right instanceof List) || ((List<?>) right).size() != 2) { throw new SpelEvaluationException(getRightOperand().getStartPosition(), SpelMessage.BETWEEN_RIGHT_OPERAND_MUST_BE_TWO_ELEMENT_LIST); } List<?> list = (List<?>) right; Object low = list.get(0); Object high = list.get(1); TypeComparator comp = state.getTypeComparator(); try { return BooleanTypedValue.forValue(comp.compare(left, low) >= 0 && comp.compare(left, high) <= 0); } catch (SpelEvaluationException ex) { ex.setPosition(getStartPosition()); throw ex; } }