The Generify refactoring is designed to transform existing code that does not use Generics, into the Generics-aware code. The refactoring analyzes existing code, and for each raw type creates safe and consistent parameter type.
Select the level of code transformation, which can be a method, a class, a package or directory, in the Project or Structure view, or place the cursor on the class or method name in the editor. If you want to apply generics to a single code fragment, select one in the editor.
On the main menu, or on the context menu, select.
In the dialog that opens, define the refactoring options.
IntelliJ IDEA tries to generate code, which is as correct as possible from the Java point of view. In other words, each context introduces some type restrictions, and the refactoring produces the best possible type (in our case
<String>) that does not contradict with the existing contexts.