[
https://issues.apache.org/jira/browse/CAMEL-24983?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18118693#comment-18118693
]
Claus Ibsen commented on CAMEL-24983:
-------------------------------------
Closed in favour of CAMEL-24984, which supports {{!}} as a negation prefix and
makes the message this issue proposed wrong.
The shapes it would have explained now evaluate: {{!${body.isEmpty()}}},
{{${!body.isEmpty()}}}, {{${body != null && !body.isEmpty()}}} and {{${body !=
null && !${body.isEmpty()}}}}. Where a {{!}} still cannot be read - a name that
is not a {{${ }}} function, such as {{${a} && !x}} - the useful advice is no
longer to compare it but to write it as {{!${x}}}, and that reworded hint is
part of CAMEL-24984 with a test.
PR https://github.com/apache/camel/pull/26822 is closed; nothing from it is
lost.
> camel-core: simple - say what to write when ! is used to negate a function
> --------------------------------------------------------------------------
>
> Key: CAMEL-24983
> URL: https://issues.apache.org/jira/browse/CAMEL-24983
> Project: Camel
> Issue Type: Improvement
> Components: camel-core
> Reporter: Claus Ibsen
> Priority: Major
>
> Simple has no boolean {{!}} prefix, so a negated function fails with a
> message that points at the operator rather than at the {{!}}:
> {noformat}
> ${body != null && !${body.isEmpty()}}
> -> Logical operator && needs a predicate on the right hand side, e.g.
> ${header.foo} == 'bar'; was: !${body.isEmpty()}
> {noformat}
> The same is true without the inner {{${ }}}: {{${body != null &&
> !body.isEmpty()}}} fails the same way. The nesting is not the problem -
> {{${body != null && ${body.isEmpty()}}}} evaluates fine - the {{!}} is.
> The message now says the comparison to write instead:
> {noformat}
> ! does not negate a function: compare it instead, so !${body.isEmpty()} is
> written as ${body.isEmpty()} == false, or negate the operator (!=, !contains)
> {noformat}
> Both {{${body.isEmpty()} == false}} and {{body.isEmpty() == false}} were
> verified to evaluate correctly.
> h3. Where it comes from
> The local-model benchmark: over 1586 route files a model wrote, the
> {{!}}-negated form appears in three separate series, alongside two other
> shapes of the same instinct ({{${body != null && ${body.size()} > 0}}}, which
> works, and {{${simple:${exchangeProperty.orderId}}}}, which reports an
> unknown function). A person writing Java or JavaScript makes the same mistake.
> Note this message should be revisited if simple gains support for {{!}} as a
> negation prefix.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)