fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.util.stream.*;
  5. import java.lang.*;
  6. import java.io.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. Repo fooRepository = new Repo();
  14.  
  15. Map<Bar, Set<Baz>> m = fooRepository.findAll()
  16. .stream()
  17. .collect(Collectors.groupingBy(Foo::getBar,
  18. Collectors.mapping(Foo::getBaz, Collectors.toSet())));
  19.  
  20. System.out.println("success");
  21. }
  22.  
  23. interface Bar {}
  24. interface Baz {}
  25. interface Foo {
  26. Bar getBar();
  27. Baz getBaz();
  28. }
  29. static class Repo {
  30. List<Foo> findAll() {
  31. return Collections.emptyList();
  32. }
  33. }
  34. }
Success #stdin #stdout 0.14s 4386816KB
stdin
Standard input is empty
stdout
success