|
@@ -49,10 +49,7 @@ public class DictionaryParserTests {
|
|
|
"{'value':'10102','text':'红富士'}" +
|
|
|
",{'value':'10103','text':'青苹果'}" +
|
|
|
//使用表达式进行解析
|
|
|
- ",{'value':'10105','text':'其他苹果'" +
|
|
|
- ",'textExpression':'${#value}[${#context[otherApple]}]'" +
|
|
|
- ",'valueExpression':'${(#context.put(\\'otherApple\\',#pattern.split(\"[ \\\\[ \\\\]]\")[1])==null)?#value:#value}'" +
|
|
|
- "}" +
|
|
|
+ ",{'id':'10105','value':'10105','text':'其他苹果'}" +
|
|
|
"]}" +
|
|
|
",{'value':'102','text':'梨子'}]" +
|
|
|
"}" +
|
|
@@ -61,7 +58,10 @@ public class DictionaryParserTests {
|
|
|
|
|
|
List<SimpleDictionaryItemEntity> itemEntities = JSON.parseArray(json, SimpleDictionaryItemEntity.class);
|
|
|
dictionaryEntity.setItems(itemEntities);
|
|
|
- this.parser = SimpleDictionaryParser.setDict(dictionaryEntity);
|
|
|
+ this.parser = new SimpleDictionaryParser<String>()
|
|
|
+ .addToTextExpression("10105", "${#value}[${#context[otherApple]}]")
|
|
|
+ .addToValueExpression("10105", "${(#context.put('otherApple',#pattern.split(\"[ \\[ \\]]\")[1])==null)?#value:#value}")
|
|
|
+ .setDict(dictionaryEntity);
|
|
|
}
|
|
|
|
|
|
//支持表达式
|