Apache Camel ValueBuilder不区分大小写

时间:2015-07-01 13:57:32

标签: apache-camel

我如何处理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);

}

2 个答案:

答案 0 :(得分:1)

目前没有此类支持。但是有一张类似的机票可以添加它。

该票证将以简单语言和值构建器添加equalsIgnoreCase支持。

答案 1 :(得分:0)

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

见这一行:

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

它使用属性B生成正则表达式,其中/ i表示“不敏感”。然后,它将正则表达式与属性A匹配。

相关问题