@Test public void findsLongestNameByCollecting() { Artist artist = LongestName.byCollecting(SampleData.getThreeArtists()); assertEquals(SampleData.johnColtrane, artist); }
public static Artist byCollecting(List<Artist> artists) { return artists.stream() .collect(Collectors.maxBy(byNameLength)) .orElseThrow(RuntimeException::new); }
LongestName { public static Artist byCollecting(List<Artist> artists) { return artists.stream() .collect(Collectors.maxBy(byNameLength)) .orElseThrow(RuntimeException::new); } }
LongestName { public static Artist byCollecting(List<Artist> artists) { return artists.stream() .collect(Collectors.maxBy(byNameLength)) .orElseThrow(RuntimeException::new); }  }
LongestName { public static Artist byCollecting(List<Artist> artists) { return artists.stream() .collect(Collectors.maxBy(byNameLength)) .orElseThrow(RuntimeException::new); }  static Artist byReduce(List<Artist> artists); static Artist byCollecting(List<Artist> artists); }
LongestName { public static Artist byCollecting(List<Artist> artists) { return artists.stream() .collect(Collectors.maxBy(byNameLength)) .orElseThrow(RuntimeException::new); }  static Artist byReduce(List<Artist> artists); static Artist byCollecting(List<Artist> artists);  }