rewrite-migrate-java icon indicating copy to clipboard operation
rewrite-migrate-java copied to clipboard

Recipes to replace Guava `Immutable{Set|List|Map}.copyOf()` with Java `{Set|List|Map}.copyOf()`

Open knutwannheden opened this issue 1 year ago • 2 comments

  • Fixes #584

Add recipes to replace Guava ImmutableSet.copyOf(), ImmutableList.copyOf(), and ImmutableMap.copyOf() calls with Java Set.copyOf(), List.copyOf(), and Map.copyOf() calls.

  • Add AbstractNoGuavaImmutableCopyOf class to provide a base for the new recipes.
  • Add NoGuavaImmutableSetCopyOf, NoGuavaImmutableListCopyOf, and NoGuavaImmutableMapCopyOf classes extending AbstractNoGuavaImmutableCopyOf.
  • Update no-guava.yml to include the new recipes.
  • Add test classes NoGuavaImmutableSetCopyOfTest, NoGuavaImmutableListCopyOfTest, and NoGuavaImmutableMapCopyOfTest with test cases for the new recipes.

For more details, open the Copilot Workspace session.

knutwannheden avatar Oct 20 '24 14:10 knutwannheden

In my opinion, a new abstract class known as AbstractNoGuavaImmutable can be created and the common methods can be added to it. We can further expand it with AbstractNoGuavaImmutableCopyOf.java and AbstractNoGuavaImmutableOf.java to eliminate the use of duplicated code.

BramliAK avatar Oct 21 '24 21:10 BramliAK

I was thinking along the same lines, especially after the improvements you added @BramliAK ; reuse between these two is likely preferred over duplication.

timtebeek avatar Oct 24 '24 11:10 timtebeek

This PR is stale because it has been open for 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Apr 16 '25 11:04 github-actions[bot]