id去重

List dList = aList.stream()
                    .filter(distinctByKey(DO::getId)).collect(Collectors.toList());


public static  Predicate distinctByKey(Function keyExtractor) {
        Map map = new ConcurrentHashMap<>();
        return t -> map.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
    }

你可能感兴趣的:(id去重)