IntelliJ IDEA 2021.1 Help

Wrap Return Value dialog

Refactor | Wrap Return Value

Use this refactoring to create a wrapper class around the return values of a method, or use a compatible existing class as a wrapper.

ItemDescription
Method to wrap returns fromThis read-only field shows the name of the selected method.
Create new classClick this radio-button to create a new wrapper class. If this option is selected, specify the class and destination package name in the fields below.
Class nameType the name of the new wrapper class.
Package nameBy default, the current package name is displayed. You can type a different package name in the text field, or click the ellipsis button and select the destination package from the tree view. If the desired package doesn't exist, click Icons actions new folder to create a new one.
Target destination directoryUse this field to select the target destination directory. By default, the current destination directory is displayed. You usually choose the target destination based on a current package. If this package exists in multiple roots, you can click arrow button and select Leave in same source root from the list. In this case, wrapper would be placed near the initial class.
You can click the ellipsis button to open Choose Destination Directory window.
You can choose Directory Structure tab to select another destination directory or choose Choose By Neighbor Class tab to place a wrapper near the neighbor class if, for example, you want to put the wrapper in util directory near your Pair or Triple classes and you do not remember the exact package, putting wrapper near the Pair class would save you time.
Use existing classClick this radio-button to use an existing class of your choice as a wrapper.
NameSpecify the name of the desired wrapper class. Note that such class should contain a constructor with a parameter of the same type as the return value in question.
You can type the fully-qualified class name in the text field, or click the ellipsis button and choose the desired class in the Select parameter class dialog box. Note that you can select the desired wrapper class both from the project and non-project classes.
Wrapper fieldSelect the field that will store the return value, from the drop-down list of fields, encountered in the specified wrapper class.
Inner classClick this radio-button to create an inner class. You might want to do that if, for example, you have a private method. In this case you can leave everything in the same class.
NameSpecify the name of the inner class.
Last modified: 08 March 2021