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?

0
6 comments

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

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

0

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

Please try $StringUtils

0
Avatar
Permanently deleted user

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



0
Avatar
Permanently deleted user

nevermind it works when you encapsulate fully

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

Please sign in to leave a comment.