For example I have many classes than implement my interface. After adding new method definition in the interface, how can I fast-add blank interface implementations for all that classes?
Alt+Enter on the new method in the interface, Implement method:
Press Enter, the list of implementation classes will be shown, select the desired classes using Shift+arrow keys or press Ctrl+A to select all of them, then press Enter again to confirm the choice. Stub implementations will be added to all the selected classes.
I think the best you can do comes from their code generation tutorial, particularly by using
Ctrl+O
in an implementing class. Otherwise I'm not aware of a way to generate an entire class.
You can generate an implementation of an interface by moving the caret to the name of the interface and pressing option+return (on Mac) or ALT+Enter (on PC), then hovering over Implement interface
and pressing return/Enter:
Please note that my caret can't be seen but it's between the h
and a
of Shape
IntelliJ will then prompt you for a class name and which methods to include in the implementation, then generate a class, like this:
In IntellyJ IDEA 12 you can use Push Members Down dialog:
Refactor -> Pull Members Down...
Then select methods you want to push to subclasses and click "Refactor": http://clip2net.com/s/i6DK41
Note that it doesn't generate the stub method by base class - it just moves it as is. So you'll need to implement the stub by yourself in the parent (root) class, e.g.:
public boolean getRequiredDatabaseNameWhenPartitioned() {
return true;
}
then use "Push members down", refactor, and finally make the method of the parent class abstract manually
© 2022 - 2024 — McMap. All rights reserved.