Extract Method Object
The Extract Method Object refactoring moves method into a new class, converting all the local variables to its fields, allowing you to decompose the method into other methods on the same object. It is an alternative to the Extract Method, and can be used when you have multiple return values in an extracted method.
Example
To extract a method object, follow these steps
- In the editor, select the method code block to be extracted into the object.
- On the main menu, or from the context menu of the selection, choose .
- Select whether you want to create inner class, or anonymous class.
- If you want to create an inner class, you need to specify the name for the class and the visibility scope. You can also make the class static, if needed.
- If you want to create an anonymous class, you should specify method's name.
- In the Parameters area select the variables that will be used as a parameters.
- Review Signature Preview and click OK.
See Also
Reference:
Last modified: 18 July 2017