美文网首页
设计模式之过滤器 Filter \ Criteria

设计模式之过滤器 Filter \ Criteria

作者: 音符纸飞机 | 来源:发表于2018-11-23 00:10 被阅读36次

这个设计模式好无聊。。
java里stream的filter, groupingBy

Map<Integer, List<Person >> groupMap = persons.stream().collect(Collectors.groupingBy(Person::getGender));
List<Person> men = people.stream()
        .filter(o -> o.getGender() == Gender.Male)
        .filter(o -> o.getAge() >= 23)
        .collect(Collectors.toList());

相关文章

网友评论

      本文标题:设计模式之过滤器 Filter \ Criteria

      本文链接:https://www.haomeiwen.com/subject/spnrqqtx.html