How to properly check for Boolean value in Spring EL expression?
I'm a bit new to using Spring Expression Language but I'm trying to see what is the best way to check a that a Boolean value is not null and true?
For type "Display" there is a property "removeMessage" which is of type
java.lang.Boolean. So I want to first check that this value is not null and that it is true. Based on if this is true or not I will either return an empty string or a calculatedMessage.
I am currently checking with below expression:
display?.removeMessage != null && display?.removeMessage ? '' : display.calculatedMessage
While this works, I was hoping to find a more nicer way to do the null and true check. I was thinking/hoping for something more like how we would check normally such as e.g. BoolenUtils.isTrue(value) (apache), or even just checking like Boolean.TRUE.equals(value) which takes care of the null check.