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 - Allow to customize generated getter/setter code
Summary: Allow to customize generated getter/setter code
Alias: None
Product: java
Classification: Unclassified
Component: Beans (show other bugs)
Version: 7.2
Hardware: PC Linux
: P4 normal with 5 votes (vote)
Assignee: Ralph Ruijs
Depends on:
Reported: 2012-11-29 23:45 UTC by mclaborn
Modified: 2016-09-19 09:28 UTC (History)
2 users (show)

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description mclaborn 2012-11-29 23:45:49 UTC
Allow (via template or some other mechanism) generated getter and setter methods.

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.