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:

  1. 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.
  2. Choose Refactor > Use Supertype Where Possible.
  3. 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.
  4. If you click Refactor, the IDE applies the changes automatically and skips the remaining steps. If you click Preview, 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. 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