Thursday Dec 06, 2012

Customizable Method Bodies in NetBeans IDE 7.3

In NetBeans IDE 7.3, bodies of newly created methods can now be customized in Tools/Templates/Java/Code Snippets, see below:

The content of the first of the two above, "Generated Method Body", is like this:

<#--
A built-in Freemarker template (see http://freemarker.sourceforge.net) used for
filling the body of methods generated by the IDE. When editing the template,
the following predefined variables, that will be then expanded into
the corresponding values, could be used together with Java expressions and
comments:
${method_return_type}       a return type of a created method
${default_return_value}     a value returned by the method by default
${method_name}              name of the created method
${class_name}               qualified name of the enclosing class
${simple_class_name}        simple name of the enclosing class
-->
throw new java.lang.UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

The second one, "Overriden Methody Body", is as follows:

<#--
A built-in Freemarker template (see http://freemarker.sourceforge.net) used for
filling the body of overridden methods generated by the IDE. When editing
the template, the following predefined variables, that will be then expanded
into the corresponding values, could be used together with Java expressions and
comments:
${super_method_call}        a super method call
${method_return_type}       a return type of a created method
${default_return_value}     a value returned by the method by default
${method_name}              name of the created method
${class_name}               qualified name of the enclosing class
${simple_class_name}        simple name of the enclosing class
-->
<#if method_return_type?? && method_return_type != "void">
return ${super_method_call}; //To change body of generated methods, choose Tools | Templates.
<#else>
${super_method_call}; //To change body of generated methods, choose Tools | Templates.
</#if>
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« December 2012 »
SunMonTueWedThuFriSat
      
1
15
23
24
25
29
     
Today