Java Reference
In-Depth Information
room in this book to cover all of them. We'll discuss some of the most powerful
options, but it will be time well spent if you look up IDEA 's latest refactorings.
Extracting an interface to introduce abstraction
The Extract Interface refactoring allows you to create a new interface using an
existing class as a template. Execute Refactor | Extract Interface to bring up the
refactoring dialog shown in figure 9.23. In this example, we're taking an existing
class FixedRateCurrencyExchangeService and extracting a generic Scalable inter-
face from it.
Begin by choosing one of two options: Extract interface or Rename original .
In the first case, the new interface is created in the specified new location, and the
current class contains its actual implementation. If you choose to rename the origi-
nal class, the extracted interface obtains the current name and location, whereas
the actual implementation is moved to the new location with the new name.
Then specify a name and package for the new interface. Select the methods
(and constants, if any) that you wish to include in the new interface. The method
signatures are copied over as is, but you can use the Change Method Signature
refactoring command to fine-tune them later. Finally, select one of the JavaDoc
options to tell IDEA what to do with any JavaDoc comments on the methods
going into the new interface. Your choices are as follows:
Figure 9.23
The Extract Interface
refactoring lets you select
a set of already-
implemented methods in a
class and use them to
define a new interface.
 
 
 
 
 
 
 
Search WWH ::




Custom Search