我有一个 Java 对象列表(假设 getter 和 setter):
Record(String name, String part, String value);
如果列表包含某个name值和某个值,我需要返回一个布尔part值。
我一次只为一个过滤器工作:
//assume records are added to this list
List<Record> masterList = new ArrayList<Record>();
boolean check = masterList.stream().map(Record::getName).filter(record.getName()::equals).findFirst().isPresent();
但是我对此尝试出错Non-static method cannot be referenced from a static context:Record::getPart
masterList.stream().map(Record::getName).filter(record.getName()::equals).map(Record::getPart).filter(record.getPart()::equals).findFirst().isPresent();
慕慕森
相关分类