Skip to content

grzegorzwitkowski/BuilderDeluxe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BuilderDeluxe

BuilderDeluxe is a plugin for IntelliJ IDEA that automates creation of builder classes for POJOs. Let's say you have a class Person with fields age, firstName and lastName:

public class Person {

    private String firstName;
    private String lastName;
    private int age;

    public Person(String firstName, String lastName, int age) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.age = age;
    }

    public String getFirstName() {
        return firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public int getAge() {
        return age;
    }
}

With BuilderDeluxe you can press ALT+Insert to generate builder class:

public static class Builder {
    private String firstName;
    private String lastName;
    private int age;

    private Builder() {
    }

    public static Builder person() {
        return new Builder();
    }

    public Builder withFirstName(String firstName) {
        this.firstName = firstName;
        return this;
    }

    public Builder withLastName(String lastName) {
        this.lastName = lastName;
        return this;
    }

    public Builder withAge(int age) {
        this.age = age;
        return this;
    }

    public Person build() {
        return new Person();
    }
}

and use it that way:

Person person = person().withFirstName("John").withLastName("Doe").withAge(42).build();

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages