public static String toString(Iterable<?> list) {
   if (list == null) {
     return "(null)";
   } else {
     return Iterators.toString(list.iterator());
   }
 }
 private void printSourcesOfArticles(
     List<Article> articles, Map<GeneralSource, List<Source>> generalSources) {
   System.out.println(
       "Selected articles: "
           + Iterators.toString(articles.stream().map(article -> article.getTitle()).iterator()));
   for (GeneralSource generalSource : generalSources.keySet()) {
     List<Source> sources = generalSources.get(generalSource);
     System.out.println(generalSource.getName() + " " + sources.size() + "x");
   }
 }
예제 #3
0
 /**
  * Returns a string representation of {@code iterable}, with the format {@code [e1, e2, ..., en]}.
  */
 public static String toString(Iterable<?> iterable) {
   return Iterators.toString(iterable.iterator());
 }