자바 필터 집합

740 단어
public RestResult> getUserBelongsItems(EmptyParam param) {
    List results = new ArrayList<>();
    List communityUserList= communityUserBaseService.getValidInfoByMemberId(param);
    List collect = communityUserList.parallelStream().filter(distinctByKey(CommunityUser::getCommunityCode)).collect(Collectors.toList());
    return RestResult.wrapSuccessResponse(results);
}

public static  Predicate distinctByKey(Function super T, ?> keyExtractor) {
    Set seen = ConcurrentHashMap.newKeySet();
    return t -> seen.add(keyExtractor.apply(t));
}

좋은 웹페이지 즐겨찾기