I have:
To reduce the number of classes, I want A and B to be merged into one class, and let the other class(es) extend from the new merged class.
What is the name of this refactoring?
P.S. In my implementation it is in Java, can this refactoring be done automatically in IntelliJ?
No, you can't.
Definitions: A class that is derived from another class is called a subclass (also a derived class, extended class, or child class). The class from which the subclass is derived is called a superclass (also a base class or a parent class).
If more than one superclass defines a property, method, or event having the same name, there must be an unambiguous resolution to the multiple definitions. You cannot derive a subclass from any two or more classes that define incompatible class members.
IntelliJ's Inline Superclass performs the merging of a superclass to subclass.
Inline Superclass
You will be inlining class A and intellij supports that. Just right click on the class name and select "refactor" from the pop-up and inlining the class should be an option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With