Apache Camel ValueBuilder is case insensitive

How can I handle equalsIgnoreCase?

The following can handle isEqualTo, can it be done without doing anything inside the processor?

@Test
public void testPreicateProperties() throws Exception {
    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:a")
                .setProperty("A", constant("ab"))
                .setProperty("B", constant("aB"))
                .setHeader("A",  constant("ab"))
                .setHeader("B", constant("aB"))
                .choice()
                    .when(PredicateBuilder.and(exchangeProperty("A").isEqualTo(exchangeProperty("B"))))
                        .log("Equal properties")
                    .otherwise()
                        .log("Not Equal properties")
                .endChoice()
                .choice()
                    .when(PredicateBuilder.and(header("A").isEqualTo(header("B"))))
                        .log("Equal headers")
                    .otherwise()
                        .log("Not Equal headers")
                ;
        }
    });

    template.sendBody("direct:a", "body");

    Thread.sleep(1500);

}

      

+3


source to share


2 answers


There is currently no such support. But there is a similar ticket to add this.



This ticket will add plain language equalsIgnoreCase support as well as a value builder.

+1


source


You can use a language Simple

(see here ) to create a regex and then configure it to be case insensitive.

See this line:



when(exchangeProperty("A").matches(constant("${exchangeProperty.B}/i")))

      

It uses property B to generate a regex where / i indicates "insensitive". Then it matches a regular expression with property A.

0


source







All Articles