So, there already is a way to generate an implementation of a class in IntelliJ (v11), but it is rather simple.
It will create a class with all the methods necessary to satisfy the interface. These methods are empty and return null where appropriate.
What I am looking for is a plugin or something that will generate beans from a interface. If the generator sees a method getXXXX or setXXX (or isXXX) in the interface, it will create a member of that type and get or return that member, respectively in the implemented class.
Create an interface based on the methods of a class. Rename the original class, and it implements the newly created interface. In such case, IntelliJ IDEA changes all usages of the original class to use the interface where possible. In addition, static final fields, declared in the initial class, can be moved to an interface.
Some of us may prefer to implement builders as static inner classes as described by Joshua Bloch in Effective Java. If this is the case, we need to take a few extra steps to achieve this using IntelliJ's Replace Constructor with Builder feature. First of all, we need to manually create an empty inner class and make the constructor private:
With the Extract Interface refactoring you have the following options: 1 Create an interface based on the methods of a class. 2 Rename the original class, and it implements the newly created interface. In such case, IntelliJ IDEA changes all usages... More ...
JavaBeans are classes that encapsulate many objects into a single object (the bean). It is a java class that should follow following conventions: Must implement Serializable. It should have a public no-arg constructor. All properties in java bean must be private with public getters and setter methods. public class TestBean {.
All you can do is create a new class that implements the interface, then tell IntelliJ to implement all the methods. From that point, it's up to you to fill in the meat of the methods. There's no magic that I know of.
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