Set getter and setter templates to refer to the as inside the template, below gives my own template to use
1. Select getter and Setter in the Code-->generate (Atl+inset)--pop-up panel in the As menu bar
2, click on the icon behind the Getter Templete, pop up the following panel
3. Click + Add a template, copy the code below to the new panel and save it
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}
4, Setter Templete Similarly, click on the following icon, create a new template, enter the code below to
#set ($paramName = $helper. Getparamname ($field, $project)) Public # # #if ($field. modifierstatic) Static # # #endvoid 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}
Getter and Setter templates configuration in Android Studio