Java8 according to the object attribute value to a heavy

The duplicate object is repeated in an attribute list there is an object to heavy

//根据skuAttrValueName值去重
            List<SkuValue> uniqueSkuValues = skuValues.stream().collect(
                    Collectors.collectingAndThen(Collectors.toCollection(
                            () -> new TreeSet<>(Comparator.comparing(o -> o.getSkuAttrValueName()))), ArrayList::new)
            );

 

Guess you like

Origin www.cnblogs.com/tongxuping/p/10930998.html
Recommended