Skip to content

Latest commit

 

History

History
76 lines (54 loc) · 1.88 KB

README.md

File metadata and controls

76 lines (54 loc) · 1.88 KB

innerbuilder

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.

screenshot

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);
    }
  }
}

Installation

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.

Manual installation

Copy innerbuilder.jar to your ~/.IntelliJIdea12/config/plugins directory.

Usage

Use Shift+Alt+B or Alt+Insert and select Builder. Choose the fields to be included and press OK.

Rate

If you enjoy this plugin, please rate it on it's plugins.jetbrains.com page.

License

Licensed under the Apache License, Version 2.0.

Copyright 2013 Mathias Bogaert.