Categories


opensource software

GenerateBuilder

Products: IntelliJ IDEA

Vendor: Tim Tennant, Mike Dunford

Email:

Website: N/A

License: http://www.opensource.org/licenses/bsd-license.php

Bugtracker page

Description:

This plugin adds builder actions to the generate menu (ctrl + n). Actions to generate builders and builder with methods.
  • 'with methods' action (ctrl + shift + w) generates a withFieldName() method in current class for each of the classes fields you select (works like the generate getter/setter). The with method returns the current class.
  • 'generate builder' action (alt + shift + b) generates a builder class in the current package for the current class, that has a withFieldName() method for each field in the class, and a build() method that constructs and returns a new instance of the class.
Downloads: 4126
Rating:
Participated in rating: 2
Version Since Build Until Build File/URL Size (Kb) Date Details
1.1. 80.8000. . Download 118.32 2009-01-08 12:23:44 details
. .
1 update is hidden show all updates

General usage instructions:

Select with on Generate menu (alt+ins on window, ctrl+n on mac)

Comments:

Anonymous
Rated:
2009-11-13 16:22:44
Hi,

I was looking for a plugin to do exactly this, and found your plugin. It certainly is very useful, but I am missing one feature which would make my life much easier: it would be nice if every builder had a constructor taking the type you are building, in order to \"prepopulate\" the values in the map.

For example if you have a class Person and a PersonBuilder, you could do

Person existing = findPersonFromSomewhere();
Person updated = new PersonBuilder(existing).withName(\"new name\").build();

In stead of having to set every property which doesn\'t change in the existing person again...

It can be implemented like this:

public PersonBuilder(Person person)
{
try
{
for (Field field : person.class.getDeclaredFields())
{
field.setAccessible(true);
values.put(field.getName(), field.get(person));
}
} catch (IllegalAccessException e)
{
throw new AssertionError(\"shouldn\'t happen\");
}
}

Thanks,
Jan
.
Anonymous
Rated:
2008-12-22 19:30:06
Brilliant if you are using the builder plugin
.