Prefer the Java standard library instead of Guava
MSALGuava filled in important gaps in the Java standard library and still does. But at least some of Guava's API surface area is covered by the Java standard library now, and some projects may be able to remove Guava altogether if they migrate to standard library for these functions.
org. openrewrite. java. migrate. guava. NoGuavamod run . --recipe= org. openrewrite. java. migrate. guava. NoGuavaInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.
Recipe list
It runs these recipes, in this order.
- Keep the type arguments of Guava's collection factories
- Prefer the Java 11 standard library instead of Guava
- Prefer the Java 21 standard library instead of Guava
- Upgrade Gradle or Maven dependency versions
io.springfox:springfox-swagger2:2.10.x - Prefer
Files#createTempDirectory() - Prefer
new String(Files.readAllBytes(path), charset) - Prefer
Runnable::run - Prefer
Collection.stream().anyMatch(Predicate) - Prefer
Collection.stream().map(Function)overIterables.transform - Prefer
new ArrayList<>(Arrays.asList(..)) - Prefer
if/throwover Guava'scheckArgumentandcheckState - Prefer
Objects.requireNonNull(T, Supplier<String>) - Prefer
A.class::isInstance - Prefer
Arrays.asList(..)over Guava primitives - Refaster style Guava to Java migration recipes
- Prefer
Collection.stream().filter(Predicate) - Prefer
new HashSet<>() - Prefer
s == null || s.isEmpty() - Prefer
java.nio.charset.StandardCharsets - Prefer
java.util.Optional - Prefer
java.util.function.Function - Prefer
java.util.function.Predicate - Prefer
java.util.function.Supplier - Prefer
java.util.Objects#equals - Prefer
java.util.Objects#hash - Prefer
java.util.Collections#unmodifiableNavigableMap - Prefer
java.util.Collections#synchronizedNavigableMap - Prefer
Character#compare - Prefer
Integer#compare - Prefer
Long#compare - Prefer
Short#compare - Prefer
Integer#compareUnsigned - Prefer
Integer#divideUnsigned - Prefer
Integer#parseUnsignedInt - Prefer
Integer#remainderUnsigned - Prefer
String#join()over GuavaJoiner#join() - Prefer
Long#compareUnsigned - Prefer
Long#divideUnsigned - Prefer
Long#parseUnsignedLong - Prefer
Long#remainderUnsigned - Prefer
Math#addExact - Prefer
Math#subtractExact - Prefer
Math#multiplyExact