Skip to content

Recipe to transform uses of Collections.unmodifiableXX to Immutable Static Factory Methods #67

@yeikel

Description

@yeikel

I believe that this belongs here (otherwise please let me know under what module this should be reported)

it would be nice to add a rule to the Java 8 -> Java 11 migration to apply the following transformation :

Before :

Set<String> s = Collections.unmodifiableSet(new HashSet<>(Arrays.asList("A", "B")));

After

Set<String> s = Set.of("A", "B")

Additional resources :

See : https://docs.oracle.com/en/java/javase/11/core/creating-immutable-lists-sets-and-maps.html#GUID-930A5334-9413-4E87-A1D7-6FF4E9E421B2

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions