Created
November 28, 2014 14:43
-
-
Save oehme/6fba9907ea5e8a7f1192 to your computer and use it in GitHub Desktop.
Generating Methods from Messagekeys
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
Iterators.forEnumeration(resourceBundle.keys).forEach [ key | | |
cls.addMethod(key.keyToMethodName) [ | |
patternVariables.forEach [ patternVariable, index | | |
addParameter("arg" + index, patternVariable.argumentType(context)) | |
] | |
returnType = string | |
body = ''' | |
«String» pattern = bundle.getString("«key»"); | |
«MessageFormat» format = new «MessageFormat»(pattern); | |
return format.format(new «Object»[]{«parameters.join(", ")[simpleName]»}); | |
''' | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment