Search code examples
intellij-ideagetter-settergenerated-code

How can I change the visibility of setter method by Intellij code generator?


In my code generator, I saw the default visibility is public, so all methods generated is public, although I customized myself template of setter. enter image description here

My template: enter image description here Now, I need public getter and protected setter. How can I do?


Solution

  • You just can't, I'm afraid.

    Like the text at the bottom of IDEA's "Customize Template" dialog says:

    "Visibility is applied according to File | Settings | Editor | Code Style | Java | Code Generation".

    That setting does not distinguish between getters and setters, unfortunately.

    You can always create a feature request at https://youtrack.jetbrains.com/