InterlliJ 定制Getter and Setter分享
2016-07-07 22:36
260 查看
Getter@Lovell:
Setter@Lovell
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
/** * 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") && $StringUtil.isCapitalized($StringUtil.substringAfter($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@Lovell
#if ($StringUtil.startsWith($helper.getPropertyName($field, $project),"_")) #set($paramName = $StringUtil.substringAfter($helper.getParamName($field, $project),"_")) #elseif ($StringUtil.startsWith($helper.getPropertyName($field, $project),"m") && $StringUtil.isCapitalized($StringUtil.substringAfter($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
相关文章推荐
- Minimum Window Substring
- android CoordinatorLayout使用
- 剑指offer--6.旋转数组的最小数字
- Oracle中的数据类型简介
- Android动画
- Linux-PAM(Linux下的密碼認證和安全机制)系統管理員指南(中文版)
- 启示录:打造用户喜爱的产品
- SYSU-7, Gym 100273J, trie+hash
- 提高项目25.3选择排序
- 160. Intersection of Two Linked Lists
- 【数据库】sql server中的sys.sysobjects系统表
- Oracle GoldenGate概述
- php安装扩展模块(curl模块)
- C++sort函数的用法
- 从豌豆荚到豆瓣 情怀拖延病值不值?
- 如何使用OpenSSL工具生成根证书与应用证书
- ADO.net:数据库的增删改查
- 如何进行python性能分析?
- socket参数的设置
- leetcode: Binary Tree Postorder Traversal