At my last job I went a little deeper in the enum version:
public enum Messages {
@Error
@Text("You can''t put a {0} in a {1}")
XYZ00001_CONTAINMENT_NOT_ALLOWED,
...
}
@Error, @Info, @Warning are retained in the class file and are available at runtime. (We had a couple of other annotations to help describe message delivery as well)
@Text is a compile-time annotation.
I wrote an annotation processor for this that did the following:
I wrote a few utility routines that helped log errors, wrap them as exceptions (if desired) and so forth.
I'm trying to get them to let me open-source it... -- Scott