Skip to content

Instantly share code, notes, and snippets.

@CandleCandle
Forked from evetools/gist:1235586
Created September 22, 2011 18:31
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 CandleCandle/1235589 to your computer and use it in GitHub Desktop.
Save CandleCandle/1235589 to your computer and use it in GitHub Desktop.
private static enum DBColumnTypes {
BOOL(1) {
@Override public void process(Args arguments) {
// do stuff here that you would otherwise do in the switch block
}
},
;
private final int num;
private DBColumnTypes(int type) {
this.num = type;
}
public abstract void process(Args arguments);
public static get(int idx) {
for (DBColumnTypes t : values()) {
if (t.num == idx) {
return t;
}
}
throw new IllegalArgumentException("message here");
}
}
Usage:
DBColumnTypes.get(1).process();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment