Skip to content

Instantly share code, notes, and snippets.

@danielrohers
Last active August 29, 2015 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielrohers/386156b9d06ab030ceb6 to your computer and use it in GitHub Desktop.
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.
/**
* @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