Issue Details (XML | Word | Printable)

Key: CSC-663
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Ron Smith
Reporter: Ron Smith
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Fornax Cartridge Sculptor

Generate Builder classes for domain classes

Created: 16/Oct/11 03:19 AM   Updated: 21/Jan/12 10:02 PM
Component/s: Generator
Affects Version/s: 2.1.0
Fix Version/s: 2.1.0

Time Tracking:
Original Estimate: 8 hours
Original Estimate - 8 hours
Remaining Estimate: 8 hours
Remaining Estimate - 8 hours
Time Spent: Not Specified
Remaining Estimate - 8 hours


 Description  « Hide
Add optional feature to generate a builder class for each domain object class.
The builder class provides a fluent interface to build domain objects in a manner that can be easier to work with and read.

Example of builder class use:

Person sam = new PersonBuilder()
  .firstName("Sam")
  .lastName("Smith")
  .phone("1111111111")
  .email("sam@some.com")
  .build();

Example using static import:

import static sample.builder.PersonBuilder.person;
import static sample.builder.AddressBuilder.address;

Person sam = person().
  .firstName("Sam")
  .lastName("Smith")
  .phone("1111111111")
  .email("sam@some.com")
  .homeAddress(
    address().street("111 some way").zip("11111").build())
  .build();

Builders always provide a no-args constructor in addition to the minimal constructor. They support setting attributes, single and multi-references into the domain class.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Ron Smith added a comment - 11/Nov/11 03:59 AM
Made additional changes to not generate builder for abstract classes.
Also, fornax-utilities-xtendtools 1.0.1 which this feature depends on is now in the Fornax repository, so this feature should build clean.