So here’s what I mean.
Let’s say I have a class ErrorMessages which holds all my error messages as static constants. So I could access them like ErrorMessages.PASSWORD_INVALID or ErrorMessage.PASSWORD_TOO_SHORT. I want to know if it is possible to have separate classes that hold subset of these constants and access them like ErrorMessages.PASSWORD.INVALID or ErrorMessages.PASSWORD.TOO_SHORT, etc.
This way I can more structured static structure and makes it much easier to use autocomplete.
I tried few different ways and couldn’t figure out if this was possible..
So here’s what I mean. Let’s say I have a class ErrorMessages which holds
Share
Declare them as const Objects in the static class – you won’t get them in auto complete though.
If auto complete is important, create a dedicated
com.domain.errorspackage and declare different classes for different categories of errors (like PASSWORD, FILE etc) within that package. Now declare public static constants inside those classes as appropriate.