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 223023

Summary: Allow to customize generated getter/setter code
Product: java Reporter: mclaborn <mclaborn>
Component: BeansAssignee: Ralph Ruijs <ralphbenjamin>
Status: RESOLVED WORKSFORME    
Severity: normal CC: j_schumann, markiewb
Priority: P4    
Version: 7.2   
Hardware: PC   
OS: Linux   
Issue Type: ENHANCEMENT Exception Reporter:

Description mclaborn 2012-11-29 23:45:49 UTC
Allow (via template or some other mechanism) generated getter and setter methods.

Details:
If I have a field

   private String stuff;

The generated setter is

   public void setStuff(String stuff) {
     this.stuff = stuff;
   }

I want it to be as follows, to comply with a particular customer's naming statndards:

   public void setStuff(String a_stuff) {
     stuff = a_stuff;
   }

Less important, but still useful: I'd also like to be able to select from a variety of templates from the invoking menu.  Using the above example for String, the "default" template would be as shown, but a "set to null" type of template would set the resulting field to null if the incoming value is blank/empty.

Also helpful: allow generated Javadoc that incorporates any existing comments/javadoc on the field in question.
Comment 1 Ralph Ruijs 2014-01-29 14:29:46 UTC
In NetBeans 8.0 it is possible to change the naming format used. In Tools->Options->Formatting->Java->Naming you can change the prefix/suffix to comply with your coding standard.

Changing the "template" on invocation is not something I think we would want. Personally I do not like prefix's/suffix's, but I think we all agree that the code style in a project should be consistent.