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 241416 - Have getters and setters, what about withs?
Summary: Have getters and setters, what about withs?
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Beans (show other bugs)
Version: 8.0
Hardware: PC Other
: P3 normal with 1 vote (vote)
Assignee: Ralph Ruijs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-05 02:44 UTC by djc391
Modified: 2015-12-22 14:16 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description djc391 2014-02-05 02:44:56 UTC
Netbean's insert code is a great feature to very quickly build classes. I find myself using it to create getters and constructors for all my classes. But I have recently gotten into the habbit of instead of using setters using with methods. For example

public void setId(String id){
    this.id = id;
}

public Object withId(String id){
    this.id = id;
    return this;
}

I believe that most of work needed to add this feature has already been done with the set methods. I find that editing the set methods can break things that use 
"standard" setter notation.
Comment 1 ma.schroed 2015-12-22 14:13:40 UTC
This is a good idea: to make getter/setters more customizable. I just read an article where the autor suggest to avoid the get/set prefix.

A method to set a field looks like this:

public void height(int value) {
...
}

And a method to get the value is also simple:

public int height() {
Comment 2 ma.schroed 2015-12-22 14:16:02 UTC
Oh, I was not done yet: The getters and stters could be provided by a code template. So that everyone can change it to their needs.