Getter:
/** * Getter method for property <tt>$field.name</tt>. * * @return property value of $field.name */ public ## #if($field.modifierStatic) static ## #end $field.type ## #if ($StringUtil.startsWith($helper.getPropertyName($field, $project),"_")) #set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($StringUtil.substringAfter($helper.getPropertyName($field, $project),"_")))) #elseif ($StringUtil.startsWith($helper.getPropertyName($field, $project),"m")) #set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($StringUtil.substringAfter($helper.getPropertyName($field, $project),"m")))) #else #set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))) #end#if ($field.boolean && $field.primitive) #if ($StringUtil.startsWithIgnoreCase($name, 'is')) #set($name = $StringUtil.decapitalize($name)) #else is## #end #else get## #end ${name}() { return $field.name; }
Setter Hungary(匈牙利)码风:
/** * Setter method for property <tt>$field.name</tt>. * * @param $field.name value to be assigned to property $field.name */ #set($paramName = $helper.getParamName($field, $project)) #if($field.modifierStatic) static ## #end #if ($StringUtil.startsWith($helper.getPropertyName($field, $project),"_")) void set$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($StringUtil.substringAfter($helper.getPropertyName($field, $project),"_")))($field.type $paramName) { #elseif ($StringUtil.startsWith($helper.getPropertyName($field, $project),"m")) void set$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($StringUtil.substringAfter($helper.getPropertyName($field, $project),"m")))($field.type $paramName) { #else void set$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))($field.type $paramName) { #end #if ($field.name == $paramName) #if (!$field.modifierStatic) this.## #else $classname.## #end #end $field.name = $paramName; }
Setter:(OC码风)
#if ($StringUtil.startsWith($helper.getPropertyName($field, $project),"_")) #set($paramName = $StringUtil.substringAfter($helper.getParamName($field, $project),"_")) #elseif ($StringUtil.startsWith($helper.getPropertyName($field, $project),"m")) #set($paramName = $StringUtil.substringAfter($helper.getParamName($field, $project),"m")) #else #set($paramName = $helper.getParamName($field, $project)) #end /** * Setter method for property <tt>$field.name</tt>. * * @param $paramName value to be assigned to property $field.name */ #if($field.modifierStatic) static ## #end void set$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($paramName))($field.type $paramName) { #if ($field.name == $paramName) #if (!$field.modifierStatic) this.## #else $classname.## #end #end $field.name = $paramName; }
StringUtil的源码在http://grepcode.com/file/repository.grepcode.com/java/ext/com.jetbrains/intellij-idea/12.0/com/intellij/openapi/util/text/StringUtil.java这个链接
参考:http://blog.csdn.net/aerfahaidao/article/details/50733128