Apache Camel ValueBuilder 不区分大小写

Apache Camel ValueBuilder case insensitive

如何处理 equalsIgnoreCase?

以下只能处理isEqualTo,是否可以不在处理器内部做任何事情就可以做到这一点?

@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);

}

目前暂无此类支持。但是有一个类似的票要补充一下。

该票证将在简单语言中添加对 equalsIgnoreCase 的支持,并为值生成器添加支持。

您可以使用 Simple 语言(参见 here)创建正则表达式,然后将其配置为不区分大小写。

看到这一行:

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

它使用属性 B 生成正则表达式,其中/i 表示"insensitive"。然后,它将正则表达式与 属性 A.

匹配