Created
May 31, 2010 20:46
-
-
Save bherrmann7/420266 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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