Please use the Apache issue tracking system for new NetBeans issues ( !!

Bug 65315

Summary: [50cat] Customizable templates for Encapsulate Field refactoring
Product: editor Reporter: gugrim <gugrim>
Component: RefactoringAssignee: Ralph Ruijs <ralphbenjamin>
Status: RESOLVED FIXED QA Contact: issues <>
Priority: P3 Keywords: PLAN
Version: 5.x   
Target Milestone: 7.4   
Hardware: PC   
OS: Linux   
Issue Type: ENHANCEMENT Exception Report:
Bug Depends on: 228870    
Bug Blocks:    

Description gugrim 2005-09-29 10:31:53 UTC
[ BUILD # : 200509251800 ]
[ JDK VERSION : 1.5.0_04 ]

The naming convention assumed by the Encapsulate Field refactoring doesn't suit everybody. We use the following rules:

A property has a capitalized name (PN), e g "Date".
The instance variable is called "its<PN>", , e g "itsDate". Statics use "their<PN>".
The getters and setters are called "get<PN>" and "set<PN>".
The parameter to the setter is called "p<PN>", e g "pDate".

This way, the property name has the same capitalization wherever it is used.

With this naming convention, using Encapsulate Field requires quite a lot of editing of the result. A template for the field name and templates for getters and setters would solve the problem. I'd set the field name template to e g "its__NAME__". NetBeans could easily deduce that a variable called "itsDate" would have the property name "Date" and could then make this available when expanding the getters and setters template. It could also set and match against e g __LNAME__ and __UNAME__ so that the current behavior could be handled by templates also.
Comment 1 kross 2011-06-18 08:52:08 UTC

I'm working with major PHP frameworks like Zend and Symfony2. With both the convention is to break the method braces to a new line:

public function foo()
    return $this->bar;

Netbeans generates them with the starting brace in the same line:

public function foo() {
    return $this->bar;
Comment 2 Ralph Ruijs 2013-04-30 21:53:24 UTC
This should now be supported by the prefix/suffix naming support. I do not think templates are necessary as well, but please reopen if this is not sufficient.

Fixed in jet-main 80f139ccdada
Comment 3 Quality Engineering 2013-05-02 14:11:36 UTC
Integrated into 'main-golden', will be available in build *201305021042* on (upload may still be in progress)
User: Ralph Benjamin Ruijs <>
Log: #228870 - New API to support CodeStyle's prefix/suffix
#65315 #81243 #224242 - Use CodeStyle's prefix and suffix configuration
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo