davsclaus commented on PR #26824:
URL: https://github.com/apache/camel/pull/26824#issuecomment-5809230855

   Extended in `ca6d3912ceaa` so the braces form works too — a `!` inside `${ 
}` is read by the function parser, which answers the opposite of what the 
function answers.
   
   | expression | result |
   |---|---|
   | `!${body.isEmpty()}` | true |
   | `${!body.isEmpty()}` | true |
   | `${!body.containsKey('a')}` | false |
   | `${body != null && !body.isEmpty()}` | true |
   | `${!body.isEmpty() && body != null}` | true |
   | `${body != null && !${body.isEmpty()}}` | true |
   
   Two pieces: the function parser strips a leading `!`, placed **after** the 
predicate check so the `!` in `${!a && b}` negates `a` rather than the whole 
predicate; and `wrapFunctions` gives a bare negated function the `!${...}` form 
the predicate parser already knows, instead of adding a second mechanism.
   
   **Precedence is asserted with a case where the two readings differ**, since 
the obvious examples do not distinguish them:
   
   ```
   ${!body.isEmpty() && body == null}  ->  false
   ```
   
   `(!isEmpty) && (body == null)` is `true && false`. Negating the whole 
predicate would answer `true`. The nested form agrees.
   
   Also fixed on the way: the negated expression now passes `init` on to the 
function it wraps, which otherwise threw an NPE inside OGNL on first evaluation.
   
   The full camel-core suite passes again after the `wrapFunctions` change — 
**7500 tests, 0 failures** — which matters more here than for the first commit, 
since that helper is shared with the CAMEL-24921 path. `SimpleNotOperatorTest` 
is now 7 tests.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to