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
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 to share