Working with Lists and Maps
In this section you can find some examples of working with lists and maps in IntelliJ IDEA:
- To convert a parameter of a function to a map entry
- To convert Groovy map to a class instance
- To produce a list or a map
- To inline a list or a map
To convert a parameter of a function to a map entry
If a function has a lengthy list of named arguments, you can reduce it by representing parameters as map entries. For this purpose, IntelliJ IDEA suggests the Convert parameter to map entry intention action.
To convert Groovy map to a class instance
- In a Groovy method, place the caret at a map to be converted, and press Alt+Enter:
- On the context menu, choose , and specify new class name and the package where the new class will be created. If such package doesn't yet exist, click to create one.
- If necessary, choose to change return type of the method.
- Click OK to apply changes and perform conversion.
As a result, a class is created, with the fields corresponding to the keys of the original map.
To produce a list or a map
To inline a list or a map
- Place the caret on the list or map declaration, and press Ctrl+Alt+N. IntelliJ IDEA highlights the encountered usages:
- Confirm inlining:
See Also
Procedures:
Last modified: 18 July 2017