我知道答案已被接受爲這篇文章,但我遇到了同樣的問題,雖然我會給它一個鏡頭以及。
由於馬克解釋如何create you own custom settings on the getters and setters options,
我試圖使用Intellij's settings
爲getters
和setters
並定製它的方式我想成爲。
這是消氣模板的樣子對我說:
/**
*@return Gets the value of $field.name and returns $field.name
*/
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}() {
return $field.name;
}
爲了說明,我用$field.name
作爲評論的價值和使用的常規註釋結構放置方法生成開始前值。
如:
/**
*@return Gets the value of $field.name and returns $field.name
*/
這是我的二傳手模板看起來像:
/**
* Sets the $field.name
You can use get$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))() to get the value of $field.name
*/
#set($paramName = $helper.getParamName($field, $project))
publiC##
#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;
}
而對於$field.name
值是一樣的人在吸氣。 您可以隨時以這種方式自定義評論結構,並且如果需要,還可以使用其他屬性,如$classname.##
。
這只是我如何做我comments enabling in Android Studio when doing a generate getters and setters for the the fields.
希望一個小例子,這可以幫助別人的未來。祝你好運。
請正確解釋 –
標記爲「不清楚你要求」 –
試着儘可能清楚地說明你的情況。例如,包括預期結果的使用示例,以便我們瞭解您的問題。 –