Prefer Map.of(..)

MSAL

Prefer Map.of(..) instead of using Collections.singletonMap() in Java 9 or higher. Note that the resulting Map is not behaviorally equivalent: Map.of(..) throws NullPointerException when probed with containsKey(null), containsValue(null), or get(null), whereas Collections.singletonMap(..) returns false/null.

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

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.