設置Getter和Setter模版能夠參考as裏面自帶模版,下面給出我本身使用的模版api
一、在as菜單欄中的Code-->Generate(Atl+Insert)-->彈出面板中選擇Getter and Setterthis
二、點擊Getter Templete後面的圖標,彈出以下面板code
三、點擊+添加一個本身的模版,將下面代碼複製到新建的面板而後保存便可blog
public ## #if($field.modifierStatic) static ## #end $field.type ## #set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))) #if ($field.boolean && $field.primitive) #if ($StringUtil.startsWithIgnoreCase($name, 'is')) #set($name = $StringUtil.decapitalize($name)) #else is## #end #else get## #end ${name}() { #if($field.string) return $field.name == null ? "" : $field.name; #else return $field.name; #end }
四、Setter Templete同理,點擊後面的圖標,新建模版,輸入下面代碼便可get
#set($paramName = $helper.getParamName($field, $project)) public ## #if($field.modifierStatic) static ## #end void set$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))($field.type $paramName) { #if ($field.name == $paramName) #if (!$field.modifierStatic) this.## #else $classname.## #end #end #if($field.string) $field.name = $paramName == null ? "" : $paramName; #else $field.name = $paramName; #end }