private Comparator<Role> roleComparator = new Comparator<Role>() {
public int compare(Role r1, Role r2) {
return r1.getCode().compareTo(r2.getCode());
}
};
//调用方法:
Set<Role> results = new TreeSet<Role>(this.roleComparator);
Iterator<Role> it = this.entity.getRoles().iterator();
while (it.hasNext()) {
Role role = (Role) it.next();
results.add(role);
}
//或者:
Set<Role> roles = new TreeSet<Role>(this.roleComparator);
roles.addAll(selectAiUserRole.getRoles());
List集合去除重复
最新推荐文章于 2022-03-09 14:27:14 发布