The Spring Expression Language (SpEL) is a simple and powerful expression language
which helps to query and manipulate objects at runtime.
The following example shows accessing static properties using T operator.
ExpressionParser parser = new SpelExpressionParser();
//Accessing Static Properties int maxValue = parser.parseExpression("T(Integer).MAX_VALUE").getValue(Integer.class);
System.out.println("Int max value : " + maxValue);
int minValue = parser.parseExpression("T(Integer).MIN_VALUE").getValue(Integer.class);
System.out.println("Int min value : " + minValue);
double piValue = parser.parseExpression("T(Math).PI").getValue(Double.class);
System.out.println("PI value : " + piValue);
}
}
It gives the following output,
Int max value : 2147483647
Int min value : -2147483648
PI value : 3.141592653589793