Guest User

Untitled

a guest
May 27th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. // Just cut/paste this into a GroovyConsole to evaluate. (last line is used for testing)
  2. // input: MY_ENUM_NAME output: myEnumName
  3. String enumToJava(String name){
  4. boolean lastUnder=false
  5. name.collect {
  6. if(it=='_') {
  7. lastUnder = true;
  8. return ''
  9. }
  10. def c = it
  11. if(!lastUnder){
  12. c = c.toLowerCase()
  13. }
  14. lastUnder = false
  15. c
  16. }.join('')
  17. }
  18. enumToJava('ENUM_NAME_TO_JAVA_NAME')
Add Comment
Please, Sign In to add comment