Skip to content

Instantly share code, notes, and snippets.

@bherrmann7
Created May 31, 2010 20:46
Show Gist options
  • Save bherrmann7/420266 to your computer and use it in GitHub Desktop.
Save bherrmann7/420266 to your computer and use it in GitHub Desktop.
// 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')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment