Skip to content

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.

License

Notifications You must be signed in to change notification settings

tombujok/innerbuilder

 
 

Repository files navigation

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.

About

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%