You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by nomit babraa <h....@sheffield.ac.uk> on 2020/10/15 11:33:51 UTC
struggling with ternary operator on simple expression
Hi
Using the ternary operator logic as described here
http://www.davsclaus.com/2011/09/camel-29-much-improved-simple-language.html
I am trying to set a exchange property like so where
exchangeProperty.StatusMsg = 'abc'
.setProperty("StatusMsg2")
.simple("${exchangeProperty.StatusMsg} == null ? 'ee2e2e2' : 'fffffff'")
That sets StatusMsg2 to the the string
abc == null ? 'ee2e2e2' : 'fffffff'
as the value, rather than evaluating the expression.
I am using camel 2.29 and have checked my spaces are correct
if I replace with
.simple("true ? 'ee2e2e2' : 'fffffff'")
I get the string
true ? 'ee2e2e2' : 'fffffff'
If I do
simple(true ? "ee2e2e2" : "fffffff")
I then get the string
ee2e2e2
If I try
.simple("${exchangeProperty.StatusMsg} == null" ? "ee2e2e2" : "fffffff")
I get a "Type mismatch: cannot convert from String to boolean" compilation error
How do I get the first part of my ternary expression to be recognised
as an expression itself?
Thanks for any advice
n
Re: struggling with ternary operator on simple expression
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Btw working on compiled simple language (experiment now) but at first
working on a new camel-joor language that uses java code, so you can
then use javas ternary operator:
camel.apache.org/components/latest/languages/joor-language.html
On Thu, Oct 15, 2020 at 2:31 PM Claus Ibsen <cl...@gmail.com> wrote:
>
> Hi
>
> There is no support for elvis or ternary operators.
> You can use camel-groovy and groovy language for such kind
>
> The docs on the website has the details what is supported
> https://camel.apache.org/components/latest/languages/simple-language.html
>
>
>
> On Thu, Oct 15, 2020 at 2:24 PM nomit babraa <h....@sheffield.ac.uk> wrote:
> >
> > Hi
> >
> > Using the ternary operator logic as described here
> > http://www.davsclaus.com/2011/09/camel-29-much-improved-simple-language.html
> >
> > I am trying to set a exchange property like so where
> > exchangeProperty.StatusMsg = 'abc'
> >
> > .setProperty("StatusMsg2")
> > .simple("${exchangeProperty.StatusMsg} == null ? 'ee2e2e2' : 'fffffff'")
> >
> > That sets StatusMsg2 to the the string
> >
> > abc == null ? 'ee2e2e2' : 'fffffff'
> >
> > as the value, rather than evaluating the expression.
> >
> > I am using camel 2.29 and have checked my spaces are correct
> >
> > if I replace with
> >
> > .simple("true ? 'ee2e2e2' : 'fffffff'")
> >
> > I get the string
> >
> > true ? 'ee2e2e2' : 'fffffff'
> >
> > If I do
> >
> > simple(true ? "ee2e2e2" : "fffffff")
> >
> > I then get the string
> >
> > ee2e2e2
> >
> > If I try
> >
> > .simple("${exchangeProperty.StatusMsg} == null" ? "ee2e2e2" : "fffffff")
> >
> > I get a "Type mismatch: cannot convert from String to boolean" compilation error
> >
> > How do I get the first part of my ternary expression to be recognised
> > as an expression itself?
> >
> > Thanks for any advice
> >
> >
> > n
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: struggling with ternary operator on simple expression
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
There is no support for elvis or ternary operators.
You can use camel-groovy and groovy language for such kind
The docs on the website has the details what is supported
https://camel.apache.org/components/latest/languages/simple-language.html
On Thu, Oct 15, 2020 at 2:24 PM nomit babraa <h....@sheffield.ac.uk> wrote:
>
> Hi
>
> Using the ternary operator logic as described here
> http://www.davsclaus.com/2011/09/camel-29-much-improved-simple-language.html
>
> I am trying to set a exchange property like so where
> exchangeProperty.StatusMsg = 'abc'
>
> .setProperty("StatusMsg2")
> .simple("${exchangeProperty.StatusMsg} == null ? 'ee2e2e2' : 'fffffff'")
>
> That sets StatusMsg2 to the the string
>
> abc == null ? 'ee2e2e2' : 'fffffff'
>
> as the value, rather than evaluating the expression.
>
> I am using camel 2.29 and have checked my spaces are correct
>
> if I replace with
>
> .simple("true ? 'ee2e2e2' : 'fffffff'")
>
> I get the string
>
> true ? 'ee2e2e2' : 'fffffff'
>
> If I do
>
> simple(true ? "ee2e2e2" : "fffffff")
>
> I then get the string
>
> ee2e2e2
>
> If I try
>
> .simple("${exchangeProperty.StatusMsg} == null" ? "ee2e2e2" : "fffffff")
>
> I get a "Type mismatch: cannot convert from String to boolean" compilation error
>
> How do I get the first part of my ternary expression to be recognised
> as an expression itself?
>
> Thanks for any advice
>
>
> n
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2