Getter and Setter templates configuration in Android Studio

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.