Skip to content

BuilderMaster it's a library that will generate Builder code for your entities.

Notifications You must be signed in to change notification settings

leandrobortoli/BuilderMaster

Repository files navigation

BuilderMaster

BuilderMaster it's a library that will generate Builder code for your entities. Uses concepts such as DataBuilder, Method Chaining e Fluent Interface.

The original BuilderMaster was developed by wcaquino, this is a translation of the library into English.

Usage

To generate the builder code for a class, add the jar in the classpath of your code then invoke the following method:

new BuilderMaster().generateBuilderCode(YourClass.class);

The generated code will be printed on the console, just copy it. Create a class named YourClassBuilder and paste the generated code leaving only the declaration of the package.

Example

As an example, see the entity below:

package br.com.leandrobortoli.entities;

public class User {

	private String name;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}

And now, the generated code for the entity above:

package br.com.leandrobortoli.entities; //Only row that was not generated by BuilderMaster

import java.util.Arrays;
import java.lang.String;
import br.com.leandrobortoli.buildermaster.User;


public class UserBuilder {
	private User element;
	private UserBuilder(){}

	public static UserBuilder anUser() {
		UserBuilder builder = new UserBuilder();
		init(builder);
		return builder;
	}

	public static void init(UserBuilder builder) {
		builder.element = new User();
		User element = builder.element;

		
		element.setName("");
	}

	public UserBuilder withName(String param) {
		element.setName(param);
		return this;
	}

	public User build() {
		return element;
	}
}

About

BuilderMaster it's a library that will generate Builder code for your entities.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages