title

fire chief's random developer tidbits
Showing posts with label netbeans. Show all posts
Showing posts with label netbeans. Show all posts

Monday, January 23, 2012

Netbeans code templates

Apparently since Netbeans 6.9, code templates can insert the current class name, and I just found out now that 7.1 is out.  So one template I use all the time I named "logger" and now that I found this feature, I can make the template be:
private static final ${loggerType type="org.slf4j.Logger" default="Logger" editable="false"} logger = ${loggerFactory type="org.slf4j.LoggerFactory" default="LoggerFactory" editable="false"}.getLogger(${classVar editable="false" currClassName default="getClass()"}.class);

Then just by typing "logger[tab]" in inserts:
private static final Logger logger = LoggerFactory.getLogger(CurrentClassName.class);

and it even adds the imports for org.slf4j.  Nice!

This is a great little timesaver.  They have a couple in there for java.util.Logging already (logr and logr).  I need to go through the templates again.