diff --git a/README.md b/README.md
index 6a96cf9e..f11c2c44 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ For example, Modernizer can detect uses of `Vector` instead of `ArrayList`,
`String.getBytes(String)` instead of `String.getBytes(Charset)`, and
Guava `Objects.equal` instead of Java 7 `Objects.equals`.
The default configuration detects
-[roughly 200 legacy APIs](https://github.com/gaul/modernizer-maven-plugin/blob/master/modernizer-maven-plugin/src/main/resources/modernizer.xml),
+[over 200 legacy APIs](https://github.com/gaul/modernizer-maven-plugin/blob/master/modernizer-maven-plugin/src/main/resources/modernizer.xml),
including third-party libraries like
[Apache Commons](https://commons.apache.org/),
[Guava](https://github.com/google/guava),
diff --git a/modernizer-maven-plugin/src/main/resources/modernizer.xml b/modernizer-maven-plugin/src/main/resources/modernizer.xml
index fb41e6fd..ac3129fd 100644
--- a/modernizer-maven-plugin/src/main/resources/modernizer.xml
+++ b/modernizer-maven-plugin/src/main/resources/modernizer.xml
@@ -1122,6 +1122,162 @@ violation names use the same format that javap emits.
Prefer java.util.OptionalDouble.stream()
+
+ com/google/common/collect/Iterables.getOnlyElement:(Ljava/lang/Iterable;)Ljava/lang/Object;
+ 1.8
+ Prefer Stream.collect(MoreCollectors.onlyElement())
+
+
+
+ com/google/common/collect/Iterables.getOnlyElement:(Ljava/lang/Iterable;Ljava/lang/Object;)Ljava/lang/Object;
+ 1.8
+ Prefer Stream.collect(MoreCollectors.toOptional()).orElse(defaultValue)
+
+
+
+ com/google/common/collect/Iterables.frequency:(Ljava/lang/Iterable;Ljava/lang/Object;)I
+ 1.8
+ Prefer Stream.filter(element::equals).count() or Stream.filter(Predicate.isEqual(element)).count()
+
+
+
+ com/google/common/collect/Iterables.cycle:(Ljava/lang/Iterable;)Ljava/lang/Iterable;
+ 1.8
+ Prefer Stream.generate(() -> iterable).flatMap(Streams::stream)
+
+
+
+ com/google/common/collect/Iterables.cycle:([Ljava/lang/Object;)Ljava/lang/Iterable;
+ 1.8
+ Prefer Stream equivalent of this method is Stream.generate(() -> e) or Stream.generate(() -> collection).flatMap(Collection::stream)
+
+
+
+ com/google/common/collect/Iterables.concat:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/lang/Iterable;
+ 1.8
+ Prefer Stream.concat(a, b)
+
+
+
+ com/google/common/collect/Iterables.concat:(Ljava/lang/Iterable;Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/lang/Iterable;
+ 1.8
+ Prefer Streams.concat(a, b, c)
+
+
+
+ com/google/common/collect/Iterables.concat:(Ljava/lang/Iterable;Ljava/lang/Iterable;Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/lang/Iterable;
+ 1.8
+ Prefer Streams.concat(a, b, c, d)
+
+
+
+ com/google/common/collect/Iterables.concat:(Ljava/lang/Iterable;)Ljava/lang/Iterable;
+ 1.8
+ Prefer Streams.concat(...)
+
+
+
+ com/google/common/collect/Iterables.concat:([Ljava/lang/Iterable;)Ljava/lang/Iterable;
+ 1.8
+ Prefer Stream.flatMap(s -> s)
+
+
+
+ com/google/common/collect/Iterables.filter:(Ljava/lang/Iterable;Lcom/google/common/base/Predicate;)Ljava/lang/Iterable;
+ 1.8
+ Prefer Stream.filter(java.util.function.Predicate<? super T>)
+
+
+
+ com/google/common/collect/Iterables.filter:(Ljava/lang/Iterable;Ljava/lang/Class;)Ljava/lang/Iterable;
+ 1.8
+ Prefer Stream.filter(type::isInstance).map(type::cast)
+
+
+
+ com/google/common/collect/Iterables.any:(Ljava/lang/Iterable;Lcom/google/common/base/Predicate;)Z
+ 1.8
+ Prefer Stream.anyMatch(java.util.function.Predicate<? super T>)
+
+
+
+ com/google/common/collect/Iterables.all:(Ljava/lang/Iterable;Lcom/google/common/base/Predicate;)Z
+ 1.8
+ Prefer Stream.allMatch(java.util.function.Predicate<? super T>)
+
+
+
+ com/google/common/collect/Iterables.find:(Ljava/lang/Iterable;Lcom/google/common/base/Predicate;)Ljava/lang/Object;
+ 1.8
+ Prefer Stream.filter(predicate).findFirst().get()
+
+
+
+ com/google/common/collect/Iterables.find:(Ljava/lang/Iterable;Lcom/google/common/base/Predicate;Ljava/lang/Object;)Ljava/lang/Object;
+ 1.8
+ Prefer Stream.filter(predicate).findFirst().orElse(defaultValue)
+
+
+
+ com/google/common/collect/Iterables.tryFind:(Ljava/lang/Iterable;Lcom/google/common/base/Predicate;)Lcom/google/common/base/Optional;
+ 1.8
+ Prefer Stream.filter(predicate).findFirst()
+
+
+
+ com/google/common/collect/Iterables.transform:(Ljava/lang/Iterable;Lcom/google/common/base/Function;)Ljava/lang/Iterable;
+ 1.8
+ Prefer Stream.map(java.util.function.Function<? super T, ? extends R>)
+
+
+
+ com/google/common/collect/Iterables.get:(Ljava/lang/Iterable;I)Ljava/lang/Object;
+ 1.8
+ Prefer Stream.skip(position).findFirst().get()
+
+
+
+ com/google/common/collect/Iterables.get:(Ljava/lang/Iterable;ILjava/lang/Object;)Ljava/lang/Object;
+ 1.8
+ Prefer Stream.skip(position).findFirst().orElse(defaultValue)
+
+
+
+ com/google/common/collect/Iterables.getFirst:(Ljava/lang/Iterable;Ljava/lang/Object;)Ljava/lang/Object;
+ 1.8
+ Prefer Stream.findFirst().orElse(defaultValue)
+
+
+
+ com/google/common/collect/Iterables.getLast:(Ljava/lang/Iterable;)Ljava/lang/Object;
+ 1.8
+ Prefer Streams.findLast(stream).get()
+
+
+
+ com/google/common/collect/Iterables.getLast:(Ljava/lang/Iterable;Ljava/lang/Object;)Ljava/lang/Object;
+ 1.8
+ Prefer Streams.findLast(stream).orElse(defaultValue)
+
+
+
+ com/google/common/collect/Iterables.skip:(Ljava/lang/Iterable;I)Ljava/lang/Iterable;
+ 1.8
+ Prefer Stream.skip(long)
+
+
+
+ com/google/common/collect/Iterables.limit:(Ljava/lang/Iterable;I)Ljava/lang/Iterable;
+ 1.8
+ Prefer Stream.limit(long)
+
+
+
+ com/google/common/collect/Iterables.isEmpty:(Ljava/lang/Iterable;)Z
+ 1.8
+ Prefer !stream.findAny().isPresent()
+
+
com/google/common/collect/Iterators.forEnumeration:(Ljava/util/Enumeration;)Lcom/google/common/collect/UnmodifiableIterator;
1.9
diff --git a/modernizer-maven-plugin/src/test/java/org/gaul/modernizer_maven_plugin/ModernizerTest.java b/modernizer-maven-plugin/src/test/java/org/gaul/modernizer_maven_plugin/ModernizerTest.java
index af24dbe0..69fad0dd 100644
--- a/modernizer-maven-plugin/src/test/java/org/gaul/modernizer_maven_plugin/ModernizerTest.java
+++ b/modernizer-maven-plugin/src/test/java/org/gaul/modernizer_maven_plugin/ModernizerTest.java
@@ -67,6 +67,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -386,6 +387,8 @@ public void testAllViolations() throws Exception {
Modernizer modernizer = createModernizer("1.12");
Collection occurrences = modernizer.check(
new ClassReader(AllViolations.class.getName()));
+ occurrences.addAll(modernizer.check(
+ new ClassReader(Java8Violations.class.getName())));
occurrences.addAll(modernizer.check(
new ClassReader(Java10Violations.class.getName())));
occurrences.addAll(modernizer.check(
@@ -736,6 +739,38 @@ private static void method() throws Exception {
}
}
+ // TODO: move more methods from AllViolations to here
+ private static class Java8Violations {
+ private static void method() throws Exception {
+ Iterables.getOnlyElement(null);
+ Iterables.getOnlyElement(null, null);
+ Iterables.frequency(null, null);
+ Iterables.cycle((Iterable) null);
+ Iterables.cycle();
+ Iterables.concat(null, null);
+ Iterables.concat(null, null, null);
+ Iterables.concat(null, null, null, null);
+ Iterables.concat((Iterable) null);
+ Iterables.concat((Iterable) null);
+ Iterables.filter(null, (Predicate) null);
+ Iterables.filter(null, (Class) null);
+ Iterables.any(null, null);
+ Iterables.all(null, null);
+ Iterables.find(null, null);
+ Iterables.find(null, null, null);
+ Iterables.tryFind(null, null);
+ Iterables.transform(null, null);
+ Iterables.get(null, 0);
+ Iterables.get(null, 0, null);
+ Iterables.getFirst(null, null);
+ Iterables.getLast(null);
+ Iterables.getLast(null, null);
+ Iterables.skip(null, 0);
+ Iterables.limit(null, 0);
+ Iterables.isEmpty(null);
+ }
+ }
+
private static class Java10Violations {
private static void method() throws Exception {
new PrintStream((File) null, "");