If your project is using Java8, there is a very simple way to handle the de-duplication of a list based on the value of a property, using the Lamba function. The code is as follows:
List<UcShopCourseBizPojo> unique = ucShopCourseBizPojoList.stream().collect( collectingAndThen( toCollection(() -> new TreeSet<>(comparingLong(UcShopCourseBizPojo::getId))), ArrayList::new));
The feature ID of UCShopCourseBizPOJO is of the datatypetype Long. This method can be replaced with a more general method. The example code is as follows:
List<UcShopCourseBizPojo> sLists = shopCourseLists.stream().collect( Collectors.collectingAndThen(Collectors.toCollection( () -> new TreeSet<>(Comparator.comparing(c -> c.getShopId()))), ArrayList::new) );
However, this filter weight method has a disadvantage, that is, the obtained list may return random results every time. For example, to get the store course list and repeat the course with the same shopid, if the shopid of two courses is the same, it may return one course and another course each time when calling. Do not know what reason is caused by the bottom layer, put forward this method for reference only, if you know the reason can also leave a message ~