idea默认类注释文件为File Header.java,代码为
/**
* Created by ${USER} on ${DATE}.
*/
设置自己的类注释文件 class desc 步骤为:
注释代码为:
/**
* @Description
* @Author xiaoqx
* @Version V1.0.0
* @Since 1.0
* @Date $DATE
*/
方法注释的代码同样主要@后首字母大写格式化代码才不乱序:
/**
* @MethodName $method$
* @Description
$params$
* @Return $return$
* @Throw $throw$
* @Author xiaoqx @163 .com>
* @Version V1.0.0
* @Since $DATE$
*/
方法注释中设置取得变量 param的代码
groovyScript("def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {result+=' * @param ' + params[i] + ((i < params.size() - 1) ? '\\n' : '')}; return result", methodParameters())
JSON模板的代码(复制到idea里面要把每一行前的空格去掉,syso输出的格式才好看,不会出现属性之间相隔太多空格)
public java.lang.String toString() {
#if ( $members.size() > 0 )
#set ( $i = 0 )
return "{\"$classname\":{"
#foreach( $member in $members )
#if ( $i == 0 )
+ "##
#else
+ ", ##
#end
#if ( $member.array )
\"$member.name\":" + java.util.Arrays.toString($member.accessor)
#elseif ( $member.string || $member.primitive || $member.numeric || $member.boolean || $member.enum )
\"$member.name\":\"" + $member.accessor + "\""
#else
\"$member.name\":" + $member.accessor
#end
#set ( $i = $i + 1 )
#end
+ "}}";
#else
return "{$classname}";
#end
}
JSON toString() template with super.toString() 模板代码
(复制到idea里面要把每一行前的空格去掉,syso输出的格式才好看,不会出现属性之间相隔太多空格)
public java.lang.String toString() {
#if ( $members.size() > 0 )
#set ( $i = 0 )
#if ( $class.hasSuper )
#set ( $i = $i + 1 )
return "{\"$classname\":"
+ super.toString()
#else
return "{\"$classname\":{"
#end
#foreach( $member in $members )
#if ( $i == 0 )
+ "##
#else
+ ", ##
#end
#if ( $member.array )
\"$member.name\":" + java.util.Arrays.toString($member.accessor)
#elseif ( $member.string || $member.primitive || $member.numeric || $member.boolean || $member.enum )
\"$member.name\":\"" + $member.accessor + "\""
#else
\"$member.name\":" + $member.accessor
#end
#set ( $i = $i + 1 )
#end
#if ( $class.hasSuper )
+ "}";
#else
+ "}}";
#end
#else
return "{$classname}";
#end
}
System.out.println($END$);
public static void main(String[]args){
$END$
}
/** logger */
private static final Logger LOGGER = LoggerFactory.getLogger($CLASS$.class);
private static final String $varNAME$ ="$var$";