我有一个java.util.Map对象,它有String值。我需要将java.util.Map的String值之一与myString值进行比较。以下是具有更好地理解问题的值的变量。
myMap[STATE.code]="AK","MI","GA","NY","OH","CA"
myString="MI","OH"
注意:(" AK"," MI"," GA"," NY"," OH" ," CA")和(" MI"," OH")是完整的字符串值,而不是以逗号分隔的值。
我需要弄清楚是否有任何" MI"或" OH"存在于" AK"," MI"," GA"," NY"," OH",&# 34; CA&#34 ;. 因此,我将myString和myMAp [STATE.code]值视为列表'的元素。并尝试比较两者。我尝试了Collections.disjoint函数来找出列表中是否有任何常见元素。
在DSL中:
[condition][]Putting codes into variable=$code : String(this == myMap[STATE.code])
[condition][]Codes exist in list {myString}= Boolean( java.util.Collections.disjoint(java.util.Arrays.asList($code) , java.util.Arrays.asList({myString}) ) == false )
[condition][]Codes doesn't exist in list {myString}= not( Boolean ( java.util.Collections.disjoint(java.util.Arrays.asList($clientCatCode) , java.util.Arrays.asList({myString}) ) == false ))
尽管DSL已成功编译,但没有任何决定,也没有任何异常或错误。似乎这种方法不正确。任何人都可以建议我纠正我的DSL。
答案 0 :(得分:0)
如果状态代码是地图中的Key,我们可以通过检查map.containsValue(String)来检查Map中是否存在给定的String,
如果我们得到的Map值可以通过map.containsKey(String);