Eclipse plugin to generate builders using class fields.
You can specify some fields to make them mandatory in the generated builder.
Drag the install button to your eclipse.
Or
- Download the latest updatesite-version.zip archive from the
- From Eclipse go to Help > Install New Software... Click Add Button then select the archive that you have just downloaded
This plugin will add a simple unique command to the Source context menu that will let you generate Builders for your Java classes easly.
Asuming that you have a simple User java class as below
public class User {
private String firstName;
private String lastName;
private int age;
}
You can just request builder generation as shown in the screenshot below after installing the plugin and you will get the class builder generated. After the builder code generation, you will be able to instanciate your class as :
User me = User.builder().firstName("Anas")
.lastName("KHABALI")
.age(27)
.build();
Asuming that in the user class we want to make the lastName attribute mandatory.
So just select it in the list of the attributes that will show after clicking Generate Builders using Fields and you will get a builder that force the lastName attribute to be set to build an instance. I let you discover that.
// this will not compile, and you have to set the mandatory lastName attribute
User me = User.builder().firstName("Anas")
.age(27)
.build();
I let you discover that!
Please before contributing to this project have a look at our Contributor Covenant Code of Conduct.
Thanks for reading :)