IntelliJ IDEA plugin that adds a 'Builder' action to the Generate menu (Alt+Insert) which generates an inner builder class as described in Effective Java.
Follow @analytically for updates.
public class YourTypicalBean {
private final String foo;
private String bar;
private int foobar;
private YourTypicalBean(Builder builder) {
foo = builder.foo;
bar = builder.bar;
foobar = builder.foobar;
}
public static final class Builder {
private final String foo;
private String bar;
private int foobar;
public Builder(String foo) {
this.foo = foo;
}
public Builder(YourTypicalBean copy) {
this.foo = copy.foo;
this.bar = copy.bar;
this.foobar = copy.foobar;
}
public Builder bar(String bar) {
this.bar = bar;
return this;
}
public Builder foobar(int foobar) {
this.foobar = foobar;
return this;
}
public YourTypicalBean build() {
return new YourTypicalBean(this);
}
}
}In IntelliJ IDEA, go to File > Settings > Plugins. Click the Browse repositories button, in the search field, type innerbuilder.
It should show up in the plugins list. Right-click it and select Download and Install.
Copy innerbuilder.jar to your ~/.IntelliJIdea12/config/plugins directory.
Use Shift+Alt+B or Alt+Insert and select Builder. Choose the fields to be included and press OK.
If you enjoy this plugin, please rate it on it's plugins.jetbrains.com page.
Licensed under the Apache License, Version 2.0.
Copyright 2013 Mathias Bogaert.
