use of org.springframework.expression.OperatorOverloader in project spring-security by spring-projects.
the class DelegatingEvaluationContextTests method getOperatorOverloader.
@Test
public void getOperatorOverloader() {
OperatorOverloader expected = mock(OperatorOverloader.class);
when(this.delegate.getOperatorOverloader()).thenReturn(expected);
assertThat(this.context.getOperatorOverloader()).isEqualTo(expected);
}
use of org.springframework.expression.OperatorOverloader in project spring-framework by spring-projects.
the class StandardComponentsTests method testStandardOperatorOverloader.
@Test(expected = EvaluationException.class)
public void testStandardOperatorOverloader() throws EvaluationException {
OperatorOverloader oo = new StandardOperatorOverloader();
assertFalse(oo.overridesOperation(Operation.ADD, null, null));
oo.operate(Operation.ADD, 2, 3);
}
use of org.springframework.expression.OperatorOverloader in project spring-framework by spring-projects.
the class ExpressionState method operate.
public TypedValue operate(Operation op, Object left, Object right) throws EvaluationException {
OperatorOverloader overloader = this.relatedContext.getOperatorOverloader();
if (overloader.overridesOperation(op, left, right)) {
Object returnValue = overloader.operate(op, left, right);
return new TypedValue(returnValue);
} else {
String leftType = (left == null ? "null" : left.getClass().getName());
String rightType = (right == null ? "null" : right.getClass().getName());
throw new SpelEvaluationException(SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES, op, leftType, rightType);
}
}
Aggregations