codegenomeproject
Search
MarketplaceModules
PackagesCLIMCP
Sign in
  1. Marketplace
  2. Java
  3. Migrate
  4. Use modernized java.util APIs

Use modernized java.util APIs

MSAL

Certain java util APIs have been introduced and are favored over previous APIs.

org.openrewrite.java.migrate.util.JavaUtilAPIs
mod run . --recipe=org.openrewrite.java.migrate.util.JavaUtilAPIs

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.

Recipe
  1. Replace iterator().next() with getFirst()
  2. Replace List.get(int), add(int, Object), and remove(int) with SequencedCollection *First and *Last methods
  3. Prefer List.of()
  4. Prefer Map.of()
  5. Prefer Set.of()
  6. Prefer List.of(..)
  7. Prefer Map.of(..)
  8. Prefer Set.of(..)
  9. Prefer List.of(..)
  10. Prefer Set.of(..)
  11. Use Reader.of(CharSequence) for non-synchronized readers
  12. Prefer Optional.isPresent()
  13. Prefer Optional.isEmpty()
  14. Replace filter(Optional::isPresent).map(Optional::get) with flatMap(Optional::stream)
  15. Remove finalize() invocations on Deflater, Inflater and ZipFile
  16. Replace Math.random() with ThreadLocalRandom.current().nextDouble()
  17. Replace Stream.collect(Collectors.toUnmodifiableList()) with Stream.toList()
  18. Use getFirst() instead of stream().findFirst().orElseThrow()
  19. Prefer EnumSet.of(..)
  20. Prefer List.of(..)
  21. Prefer Locale.of(..) over new Locale(..)
  22. Prefer Map.of(..)
  23. Prefer Predicate.not(..) over casting to Predicate and calling negate()
  24. Prefer Set.of(..)
© Moderne, 2026
Recipe indexPrivacyTerms