Using a Supertype Where Possible
See Also
You can use the Use Supertype Where Possible command to
replace references to a type with references to one of the type's supertypes.
Before replacing those references, the IDE checks to make sure that supertype
and its members are accessible to all of the code that would be changed to reference them.
To initiate the Use Supertype Where Possible operation:
- In the Source Editor or Projects window, select the type to which you
want to apply the operation. The type can be a class, interface, or enumeration.
- Choose Refactor > Use Supertype Where Possible.
- In the Select Supertype to Use list, select the supertype that you want to be
referenced in place of the type your code currently uses.
- (Optional) If you do not want to review the changes before they are made,
clear the Preview All Changes checkbox.
- Click Next. If you have cleared the Preview All Changes checkbox, the IDE applies
the changes automatically and skips the remaining steps.
- The Refactoring window displays the lines of code that will be changed. Review
the list and clear the checkbox of any code that you do not want changed. If the
class that you are pushing members from has multiple subclasses and you do not
want the members to be pushed to all of them, be sure to clear the checkboxes
for the corresponding subclasses.
- (Optional) Double-click a file name in the Refactoring window to open the file,
or double-click a line of code to open the source file and to position the
cursor on that line of code.
- Click Do Refactoring to apply the selected changes.
- See Also
- Refactoring: Quick Reference
- Extracting a Superclass
- Extracting an Interface
- Moving a Class Member to a Superclass
- Moving a Class to Another Java Package
- Renaming a Class or Interface
- Undoing Refactoring Changes
Legal Notices