蔡妈看看

我们不是代码的搬运工,我们只生产代码

Idea 添加getter setter模版

1.getter setter模版配置

配置步骤:打开Generate生成窗口(常规选择生成getter setter模版的窗口页面,顶端入口处进入)

getter模版复制并全量替换为以下值:

/**
* Getter method for property <tt>$field.name</tt>.
*
* @return property value of $field.name
*/
#if($field.modifierStatic)
static ##
#end
$field.type ##
#set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project))))
#if ($field.boolean && $field.primitive)
  is##
#else
  get##
#end
${name}() {
  return $field.name;
}

setter模版复制并全量替换为以下值:

#set($paramName = $helper.getParamName($field, $project))
/**
* Setter method for property <tt>$paramName</tt>.
*
* @param $paramName value to be assigned to property $paramName
*/
#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
  $field.name = $paramName;
}

2. 新建java类文件时的头信息模版

配置步骤:Setting-->Editor-->File and Code Templates
右边选择Includes-->File Header
将如下模版全量粘贴进去 
/**
 * 
 * 
 * @author ${USER}
 * @version Id: ${NAME}, v 0.1 ${DATE} ${TIME} ${USER} Exp $
 */
点赞

发表评论