Commit 7fa7269e authored by Grzegorz Pietrusza's avatar Grzegorz Pietrusza

collapse lambdas

parent 1b254ac5
...@@ -56,25 +56,21 @@ public class SolutionsResource ...@@ -56,25 +56,21 @@ public class SolutionsResource
public Map<Integer, List<String>> getTeamSolutions(@Auth User user) public Map<Integer, List<String>> getTeamSolutions(@Auth User user)
{ {
Optional<Team> team = teamsRepository.getTeamByUser(user); Optional<Team> team = teamsRepository.getTeamByUser(user);
List<Solution> byTeam = solutionsRepository.getByTeam(team.get());
Map<Task, List<Solution>> collect = byTeam.stream() return solutionsRepository.getByTeam(team.get()).stream()
.collect(Collectors.groupingBy(new Function<Solution, Task>() .collect(Collectors.groupingBy(new Function<Solution, Task>()
{ {
@Override @Override
public Task apply(Solution solution) public Task apply(Solution solution1)
{ {
return solution.getTask(); return solution1.getTask();
} }
})); })).entrySet().stream()
Map<Integer, List<String>> collect1 = collect.entrySet().stream()
.collect(Collectors.toMap( .collect(Collectors.toMap(
taskSolutions -> taskSolutions.getKey().getLevel(), taskSolutions -> taskSolutions.getKey().getLevel(),
taskSolutions -> taskSolutions.getValue().stream() taskSolutions -> taskSolutions.getValue().stream()
.map(solution -> solution.getFlag().getDescription()).collect(Collectors.toList()) .map(solution -> solution.getFlag().getDescription()).collect(Collectors.toList())
)); ));
return collect1;
} }
@GET @GET
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment