Extracting a Superclass

See Also

When you extract a superclass, the IDE does the following:

To extract a superclass:

  1. Open the class containing the methods or fields you want to move to the new superclass.
  2. In the Source editor, right-click in the file and choose Refactor > Extract Superclass.
  3. The Extract Superclass dialog box opens.

  4. Type the name for your new superclass in the Superclass Name text field.
  5. Select the members you want to extract to the new superclass.
  6. (Optional) If you want to make a method abstract, select the Make Abstract checkbox for the method. If you select this checkbox, the method will be declared in the superclass as an abstract method and overridden in the current class. The method will be assigned the protected access modifier.
  7. (Optional) Clear the Preview All Changes checkbox if you do not want to preview the changes before they are made. If Preview All Changes is not selected, the IDE applies the changes automatically and skips the remaining steps.
  8. Click Next. If Preview All Changes was selected, the Refactoring window opens and displays all occurrences that will be affected by the change. Review the list and clear the checkbox of any code that you do not want changed.
  9. Click Do Refactoring in the Refactoring window to apply the changes to the selected files.
See Also
Refactoring: Quick Reference
Moving a Class Member to a Superclass
Using a Supertype Where Possible
Extracting an Interface
Extracting a Method
Renaming a Field or Method
Undoing Refactoring Changes

Legal Notices