Skip to content

Latest commit

 

History

History
75 lines (48 loc) · 3.66 KB

File metadata and controls

75 lines (48 loc) · 3.66 KB

intellij-stepbuilder-codegen-plugin

Build join discord Version Downloads Quality Gate Status Maintainability Rating Security Rating Lines of Code

A plugin to generate step builders for your Java classes. With step builder, you can easily provide fluent creation for your objects (i.e: Address.builder().ip("192.168.1.1").port(80).build();

What is the difference with a basic builder ?

The step builder enforce all mandatories (private final fields) to be setted you can never forget to provide a property anymore and it also enforce the order of declaration of elements.

In a normal builder you might forget some withName() invokation and the compilation will be fine. With a step builder, you cannot invoke .build(); while you didn't invoke all the required withXZY() methods.

Installation

  • Using IDE built-in plugin system:

    Settings/Preferences > Plugins > Marketplace > Search for "Stepbuilder Codegen" > Install Plugin

  • Manually:

    Download the latest release and install it manually using Settings/Preferences > Plugins > ⚙️ > Install plugin from disk...

Usage

Create a small class having some properties such as:

public class Animal {
  
  private final int size;
  private final String name;
  private final boolean visible;
}

Alt + insert:

Alt + insert

Then select Generate Step Builder:

Alt + insert

Choose the fields you like to have in your step builder And you can also specify some custom options such as javadoc or not etc.

Click OK

And voila you have your generated step builder right away:

Alt + insert


This project is a maintained fork of: https://github.com/iamMehedi/stepbuilder

I try to keep it running for new versions of intelliJ feel free to contribute to it if you have ideas :)

Plugin based on the IntelliJ Platform Plugin Template.