Last active
August 29, 2015 14:03
-
-
Save danielrohers/386156b9d06ab030ceb6 to your computer and use it in GitHub Desktop.
Example of enumeration, if you want to save in database to be some value of your enum. Just override getId(), returning what you want.
This file contains hidden or 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
/** | |
* @author Daniel Moura | |
* | |
*/ | |
public enum LogType { | |
CHANGE('C', 'Change'), | |
INCLUSION('I', 'Inclusion'), | |
EXCLUSION('E', 'Exclusion') | |
final String key | |
final String value | |
/** | |
* @param key | |
* @param value | |
*/ | |
LogType(String key, String value) { | |
this.key = key | |
this.value = value | |
} | |
@Override | |
public String toString() { | |
value | |
} | |
/** | |
* @return | |
*/ | |
public String getId() { | |
key | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment