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

Summary: Have getters and setters, what about withs?
Product: java Reporter: djc391
Component: BeansAssignee: Ralph Ruijs <ralphbenjamin>
Status: NEW ---    
Severity: normal CC: ma.schroed
Priority: P3    
Version: 8.0   
Hardware: PC   
OS: Other   
Issue Type: ENHANCEMENT Exception Reporter:

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.