根据列表中的某个字段进行去重
            
            
              java
              
              
            
          
          // 根据roleKey对列表去重
            return roleList.stream()
                    .map(AccountRole::getRoleKey)
                    .distinct()
                    .map(roleKey -> roleList.stream()
                            .filter(role -> role.getRoleKey().equals(roleKey))
                            .findFirst()
                            .orElse(null))
                    .filter(Objects::nonNull)
                    .collect(Collectors.toList());