Created
April 21, 2016 20:41
-
-
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.
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
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