File templates - lower, upper, camel case

I have a few file templates to generate stub Java classes.
It works well but how can I use passed variable to make field definition?
For instance I pass MyClass as the param and in stub it's:

private MyClass myClass;


public MyClass getMyClass() {
     return myClass;
}


public void setMyClass(MyClass myClass) {
     this.myClass = myClass;
}

So the question is how to make camel case name from the class name in the template?

6 comments
Comment actions Permalink

http://youtrack.jetbrains.com/issue/IDEA-107709 should allow you to use Velocity's StringUtil in file templates. Is this sufficient for your needs?

0
Comment actions Permalink

Yes, it seems good. I will test it. Thank a lot.

0
Comment actions Permalink

I tried using this in IntelliJ and CLion and got the following error.

Code:

#set( $CAMEL_NAME = StringUtils.removeAndHump( ${NAME}  )  )

Error:

Unable to parse template "C++ Test"
Error message: Encountered "StringUtils" at MyTemplate[line 1, column 21]
0
Comment actions Permalink

Please try $StringUtils

0
Comment actions Permalink

Is this available on IDEA Ultimate since it doesn't even recognise $StringUtils.



0
Comment actions Permalink

nevermind it works when you encapsulate fully

export class ${StringUtils.removeAndHump(${NAME}, ".")}) { }
3

Please sign in to leave a comment.