How to edit getter & setter templates in NetBeans?

断了今生、忘了曾经 提交于 2019-12-12 10:35:20

问题


By default NetBeans generates 3 line getters and setters like so:

public int getFoo() {
    return foo;
}

Is there a way to make it generate it in one line like so:

public int getFoo() {return foo;}

I did not find any get or set templates in Tools -> Options -> Editor -> Code Templates

Is there some other way to edit them or maybe a plugin?


回答1:


As seem you can't really, but I've found a patch in this blog post which modifies Netbeans source.




回答2:


on NB 7.2+ you can create your own generator:
though making use of Javac API in a NB modules (hard to do something better than a getter/setter)

https://platform.netbeans.org/tutorials/nbm-code-generator.html



来源:https://stackoverflow.com/questions/10636376/how-to-edit-getter-setter-templates-in-netbeans

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!