Prefer the Java standard library instead of Guava

MSAL

Guava 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.NoGuava
mod run . --recipe=org.openrewrite.java.migrate.guava.NoGuava

Install 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.

  1. Keep the type arguments of Guava's collection factories
  2. Prefer the Java 11 standard library instead of Guava
  3. Prefer the Java 21 standard library instead of Guava
  4. Upgrade Gradle or Maven dependency versions io.springfox:springfox-swagger2:2.10.x
  5. Prefer Files#createTempDirectory()
  6. Prefer new String(Files.readAllBytes(path), charset)
  7. Prefer Runnable::run
  8. Prefer Collection.stream().anyMatch(Predicate)
  9. Prefer Collection.stream().map(Function) over Iterables.transform
  10. Prefer new ArrayList<>(Arrays.asList(..))
  11. Prefer if/throw over Guava's checkArgument and checkState
  12. Prefer Objects.requireNonNull(T, Supplier<String>)
  13. Prefer A.class::isInstance
  14. Prefer Arrays.asList(..) over Guava primitives
  15. Refaster style Guava to Java migration recipes
  16. Prefer Collection.stream().filter(Predicate)
  17. Prefer new HashSet<>()
  18. Prefer s == null || s.isEmpty()
  19. Prefer java.nio.charset.StandardCharsets
  20. Prefer java.util.Optional
  21. Prefer java.util.function.Function
  22. Prefer java.util.function.Predicate
  23. Prefer java.util.function.Supplier
  24. Prefer java.util.Objects#equals
  25. Prefer java.util.Objects#hash
  26. Prefer java.util.Collections#unmodifiableNavigableMap
  27. Prefer java.util.Collections#synchronizedNavigableMap
  28. Prefer Character#compare
  29. Prefer Integer#compare
  30. Prefer Long#compare
  31. Prefer Short#compare
  32. Prefer Integer#compareUnsigned
  33. Prefer Integer#divideUnsigned
  34. Prefer Integer#parseUnsignedInt
  35. Prefer Integer#remainderUnsigned
  36. Prefer String#join() over Guava Joiner#join()
  37. Prefer Long#compareUnsigned
  38. Prefer Long#divideUnsigned
  39. Prefer Long#parseUnsignedLong
  40. Prefer Long#remainderUnsigned
  41. Prefer Math#addExact
  42. Prefer Math#subtractExact
  43. Prefer Math#multiplyExact