A new template
Two set of code templates
Three set variables
Expressions are supported groovy script, so here groovy write a script to generate a given log format string, methodParameters () is an idea built-in functions, obtain the name of the method parameter array:
[param1, param2] so put [] removed, because here is a groovy string, the string that has always been, which is converted to regular or regular script after
so requires two conversions, on behalf of \\ \, in turn string meaning [] if need \ [and \], a \ \\ need to string two years, so four is
then converted into a set of stitching on the line, the script:
groovyScript(" def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) { result+='\"'+params[i] +':\"+'+params[i]+ ((i < params.size() - 1) ? '+\",\"+' : '') }; return result", methodParameters())
四 测试
方法里面直接打ld,按tab就可以生成了:
注意: 集合的话需要重写toString方法