IntelliJ IDEA 2016.2 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 name By 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 icon_newFolder 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.
Name Specify the name of the inner class.

See Also

Last modified: 23 November 2016