spring - How to evaluate "(1.25 > 8)? (2.3125 * sin(90) * 1.25) : (2.3125 * sin(90) * 8)" in Java -


i using org.springframework.expression.spel.standard.spelexpressionparser parsing string expression when add sin(90) expression getting following error:

el1011e:(pos 50): method call: attempted call method sin(java.lang.integer) on null context object error.

any idea how solve this?

read spring expression language (spel) manual.

option 1: §9.5.12 functions:

you can extend spel registering user defined functions can called within expression string.

option 2: §9.5.9 types:

the special t operator can used specify instance of java.lang.class (the type). static methods invoked using operator well.

if go option 1, can register sin() function, , expression work unchanged.

if go option 2, how expression should look:

(1.25 > 8) ? (2.3125 * t(math).sin(90) * 1.25) : (2.3125 * t(math).sin(90) * 8)