Skip to content

Instantly share code, notes, and snippets.

@snekse
Created April 21, 2016 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snekse/0a7cb42004fcd52a495648a0f6442bbf to your computer and use it in GitHub Desktop.
Save snekse/0a7cb42004fcd52a495648a0f6442bbf to your computer and use it in GitHub Desktop.
An example of creating custom method implementations on a per enum value basis.
public enum Greetings implements CustomGreeting {
FORMAL("Hello. Pleasure to see you.") {
@Override
public String customGreeting() {
return Babelfish.get("i18n.dothraki.greeting.formal");
}
}, CASUAL("Hey, what's up.") {
@Override
public String customGreeting() {
return Babelfish.get("i18n.dothraki.greeting.casual");
}
}, RUDE("What do you want...") {
@Override
public String customGreeting() {
return Babelfish.get("i18n.dothraki.greeting.rude");
}
};
String standardGreeting;
Greetings(String standardGreeting) {
this.standardGreeting = standardGreeting;
}
public String getStandardGreeting() {
return standardGreeting;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment