How to deal with Camel Case for Eclipse Templates?

前端 未结 2 803
心在旅途
心在旅途 2021-01-11 22:22

I\'m trying to write an Eclipse template which will create getters and setters when I create an attribute. My current template works, except for the camel casing for the ge

2条回答
  •  孤独总比滥情好
    2021-01-11 23:15

    Best you can do right now is

    private ${Type} ${field};
    
    private ${Type} get${Field}() {return ${field};}
    
    private void set${Field}(${Type} ${field}) {this.${field} = ${field};}
    

    This defines separate linked variables for the upper and lower case names.

    You may be able to define a VariableResolver in a custom plugin to do this

提交回复
热议问题