LongestName { public static Artist byReduce(List<Artist> artists) { return artists.stream() .reduce((acc, artist) -> { return (byNameLength.compare(acc, artist) >= 0) ? acc : artist; }) .orElseThrow(RuntimeException::new); }  static Artist byReduce(List<Artist> artists); static Artist byCollecting(List<Artist> artists);  }
@Test public void findsLongestNameByReduce() { Artist artist = com.insightfullogic.java8.answers.chapter5.LongestName.byReduce(SampleData.getThreeArtists()); assertEquals(SampleData.johnColtrane, artist); }