Question:
How can I use Spring Expression Language to check that 2 Boolean properties are true?
For example, checking that a single property is true would use the syntax:
Example
@ConditionalOnExpression("${property.from.properties.file}")
What would be the syntax for checking property1 == true && property2 == false
? Where the properties can potentially have different values.
The answer from a similar question: How to check two condition while using @ConditionalOnProperty or @ConditionalOnExpression concatenates two strings together and performs a check like so:
Concatenation Solution
@ConditionalOnExpression("'${com.property1}${com.property2}'=='value1value2'")
That syntax seems confusing to someone reading that code and it seems like a hacky solution. There are some edge cases where the solution fails as well. I want to find the proper way to check two separate properties without concatenating the values.
Note: Also just to be clear, the answer isn't something you can easily search for from what I've seen. It seems like it would be a really simple answer but it's proving to be fairly elusive.