Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Just cut/paste this into a GroovyConsole to evaluate. (last line is used for testing)
- // input: MY_ENUM_NAME output: myEnumName
- String enumToJava(String name){
- boolean lastUnder=false
- name.collect {
- if(it=='_') {
- lastUnder = true;
- return ''
- }
- def c = it
- if(!lastUnder){
- c = c.toLowerCase()
- }
- lastUnder = false
- c
- }.join('')
- }
- enumToJava('ENUM_NAME_TO_JAVA_NAME')
Add Comment
Please, Sign In to add comment