Compare Enums in SpEL

Bernhard picture Bernhard · Feb 16, 2014 · Viewed 15.2k times · Source

At Spring's @Cacheable annotation I want to specify an unless condition.

However my return value is neither a primitive type nor a Java bean, but an Enum.

How can I compare for equality with another Enum in SpEL (Spring Expression Language)?

Answer

Bernhard picture Bernhard · Feb 16, 2014
#result == T(fully.qualified.path.to.AnEnum).A_VALUE