stream流
List<PersonalInformation> collect1 = list.stream().filter(new Predicate<PersonalInformation>() {
@Override
public boolean test(PersonalInformation personalInformation) {
return personalInformation.getStatus5() == null ? false : true;
}
}).sorted(new Comparator<PersonalInformation>() {
@Override
public int compare(PersonalInformation o1, PersonalInformation o2) {
return o1.getApplicationTime().getTime()>o2.getApplicationTime().getTime()?1:-1;
}
}).collect(Collectors.toList());
简化
List<PersonalInformation> collect1 = list.stream()
.filter((PersonalInformation personalInformation)-> personalInformation.getStatus5() == null ? false : true)
.sorted((PersonalInformation p1,PersonalInformation p2) -> p1.getApplicationTime().getTime() > p2.getApplicationTime().getTime() ? 1:-1)
.collect(Collectors.toList());
转载stream流基本使用方法