Bookmark and Share

Generating getters setters in eclipse is fairly easy. Also this plug-in makes it easy to create fields with the getter setters. However, if one wishes to generate interceptor with the template mechanism that is also possible. This plug in might provide more flexibility with the format of the getter setters as eclipse provides a way to customize the body of the getters setters only. To illustrate that let's consider sometime when one might want to create compact one line getter setters as shown below.

public String getFoo() { return foo; }

public void setFoo(String foo) { = foo; }

This has been actually proposed as an enhancement to eclipse.

With this plug-in one can create this kind of getter setters easily. The template for this is shown below. One needs to just add this to the templates-config.xml and import the templates from the fast code --> templates menu. Other kinds of getter setters can also be generated easily by modifying the templates. For rest of the documentation one can refer to the templates.

<template type="GETTER_SETTER">
		<description>Used to Create Getter Setters</description>
				#foreach ($field in ${fields})
					public ${field.type} get${,1).toUpperCase()}${}() {return ${};}
					public ${field.type} set${,1).toUpperCase()}${}(${field.type} ${}) {this.${} = ${};}

Design downloaded from Free Templates - your source for free web templates