Automatically create builder for class in Eclipse

hasanghaforian picture hasanghaforian · Apr 7, 2015 · Viewed 31.5k times · Source

Is there a way to use an automatic builder to create builder (Joshua Bloch's Builder Pattern) for classes in Eclipse? For example an option in the menu, a plugin or something else. I could not find anything under "Refactor".

Answer

jaco picture jaco · Aug 4, 2015

You may want to look at lombok annotations to generate builders without the boiler plate code. For example:

@Builder
public class MyPojo {
    private String name;
}

MyPojoBuilder.builder().name("yourame").build();

The limitation is that this doesn't seem to work with abstract classes.