Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA add final to auto-generated setters

I am trying to add the final keyword to the parameters in my auto-generated setters in IntelliJ IDEA 14. I know that I can create a copy of the current template which is used for setter methods:

#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;
}

But even after playing around with it for hours, I can't work out how to add "final" to it and get it to work in IntelliJ.

like image 711
Fritz Duchardt Avatar asked May 04 '15 15:05

Fritz Duchardt


1 Answers

You don't need to do this with templates.

Go to Settings (Windows: Ctrl+Alt+S) / Preferences (Mac: Command+,)

  • Editor | Code Style | Java
  • Select the Code Generation tab
  • Tick Make generated parameters final
like image 60
Trisha Avatar answered Oct 13 '22 05:10

Trisha