我有以下 HashMap 数据仅打印 keySet():-
[P001, P003, P005, P007, P004, P034, P093, P054, P006]
并将以下 ArrayList 数据作为输出: -
[P001]
[P007]
[P034]
[P054]
这就是为他们俩打印的方式。我想将数组列表数据与哈希映射数据一一进行比较。因此,值 [P001] 应该出现在 HashMap 中。
这是我尝试过的代码部分:-
def count = inputJSON.hotelCode.size() // Where "hotelCode" is particular node in inputJSON
Map<String,List> responseMap = new HashMap<String, List>()
for(int i=0; i<count; i++) {
Map jsonResult = (Map) inputJSON
List hotelC = jsonResult.get("hotelCode")
String id = hotelC[i].get("id")
responseMap.put(id, hotelC[i])
}
String hotelCFromInputSheet = P001#P007#P034#P054
String [] arr = roomProduct.split("#")
for(String a : arr) {
ArrayList <String> list = new ArrayList<String>()
list.addAll(a)
log.info list
log.info responseMap.keySet()
if(responseMap.keySet().contains(list)) {
log.info "Room Product present in the node"
}
}
任何帮助,将不胜感激。