Prefer Map.of(..)
MSALPrefer 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. MigrateCollectionsSingletonMapmod run . --recipe= org. openrewrite. java. migrate. util. MigrateCollectionsSingletonMapInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.