diff --git a/pom.xml b/pom.xml index 3536f71..79abde2 100644 --- a/pom.xml +++ b/pom.xml @@ -256,7 +256,7 @@ com.google.guava guava - 19.0 + 27.0.1-jre test diff --git a/src/main/resources/modernizer.xml b/src/main/resources/modernizer.xml index 0315be5..f9f5528 100644 --- a/src/main/resources/modernizer.xml +++ b/src/main/resources/modernizer.xml @@ -1044,4 +1044,28 @@ violation names use the same format that javap emits. Prefer java.util.Scanner(ReadableByteChannel, Charset) + + com/google/common/collect/Streams.stream:(Ljava/util/Optional;)Ljava/util/stream/Stream; + 1.9 + Prefer java.util.Optional.stream() + + + + com/google/common/collect/Streams.stream:(Ljava/util/OptionalInt;)Ljava/util/stream/IntStream; + 1.9 + Prefer java.util.OptionalInt.stream() + + + + com/google/common/collect/Streams.stream:(Ljava/util/OptionalLong;)Ljava/util/stream/LongStream; + 1.9 + Prefer java.util.OptionalLong.stream() + + + + com/google/common/collect/Streams.stream:(Ljava/util/OptionalDouble;)Ljava/util/stream/DoubleStream; + 1.9 + Prefer java.util.OptionalDouble.stream() + + diff --git a/src/test/java/org/gaul/modernizer_maven_plugin/ModernizerTest.java b/src/test/java/org/gaul/modernizer_maven_plugin/ModernizerTest.java index a075ab8..7e2c6e0 100644 --- a/src/test/java/org/gaul/modernizer_maven_plugin/ModernizerTest.java +++ b/src/test/java/org/gaul/modernizer_maven_plugin/ModernizerTest.java @@ -42,6 +42,9 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.OptionalDouble; +import java.util.OptionalInt; +import java.util.OptionalLong; import java.util.Scanner; import java.util.Set; import java.util.SortedMap; @@ -63,6 +66,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; +import com.google.common.collect.Streams; import com.google.common.io.BaseEncoding; import com.google.common.io.ByteStreams; import com.google.common.io.Files; @@ -483,6 +487,11 @@ private static class VoidPredicate implements Predicate { public boolean apply(Void input) { return true; } + + @Override + public boolean test(Void input) { + return true; + } } private static class VoidSupplier implements Supplier { @@ -645,6 +654,10 @@ private static void method() throws Exception { object = Collections.EMPTY_LIST; object = Collections.EMPTY_MAP; object = Collections.EMPTY_SET; + Streams.stream(java.util.Optional.empty()); + Streams.stream(OptionalInt.empty()); + Streams.stream(OptionalLong.empty()); + Streams.stream(OptionalDouble.empty()); } }