简单粗暴,直接贴代码。
//将根据行政班名称查询的class集合根据专业和年级去重
List<ClassEntity> distinctClass = classEntities.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getProfessionId() + ";" + o.getGrade()))), ArrayList::new));
List<TrainingProgramsEntity> trainingProgramsEntityList = new ArrayList<>();