This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 250611

Summary: Support builder style properties
Product: platform Reporter: Jaroslav Tulach <jtulach>
Component: Html4jAssignee: Jaroslav Tulach <jtulach>
Status: RESOLVED FIXED    
Severity: normal CC: apireviews
Priority: P3 Keywords: API_REVIEW_FAST
Version: 8.1   
Hardware: PC   
OS: Other   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: Patch with implementation

Description Jaroslav Tulach 2015-02-22 12:25:20 UTC
In certain situations it would be valuable to chain calls to setters in class generated by @Model annotation in builder-like style:

@Model(className="C", properties={
  @Property(name="a", type=String.class),
  @Property(name="b", type=String.class),
  @Property(name="c", type=String.class),
  @Property(name="d", type=String.class),
  @Property(name="e", type=String.class),
  @Property(name="f", type=String.class),
})

C c = new C().a("a").b("b").c("c").d("d").e("e").f("finish");

this could probably be done by enhancing the Model class with attribute

boolean builder() default false;

and honoring it by generating appropriate "setters" returning this.
Comment 1 Jaroslav Tulach 2015-10-29 20:32:46 UTC
Created attachment 157055 [details]
Patch with implementation
Comment 2 Jaroslav Tulach 2015-10-29 20:33:39 UTC
I'd like to make this available for version 1.3 of HTML/Java API.
Comment 3 Jaroslav Tulach 2015-11-05 21:56:52 UTC
No comments, let's integrate something like the proposed change.
Comment 4 Jaroslav Tulach 2015-11-05 22:39:55 UTC
http://hg.netbeans.org/html4j/rev/10427ce1c0ee