0

我给了pojos之类的

Customer{ List<String> groups; }

Master{
   List<String> groups;
}

我想检查像这样的条件

master1.groups.containsAny(customer1.groups);

并且

master1.groups.containsAll(customer1.groups);

我怎样才能为这两个写流口水条件?提前致谢。

4

1 回答 1

0

使用以下 Drools 函数

function boolean containsAny(List<String> sourceList, List<String> targetList){
    sourceList.retainAll(targetList);
    return sourceList.size() != 0;
}
function boolean containsAll(List<String> sourceList, List<String> targetList){
    int size = sourceList.size();
    sourceList.retainAll(targetList);
    return sourceList.size() == size;
}
于 2018-01-18T05:40:14.767 回答