-
-
Save CandleCandle/1235589 to your computer and use it in GitHub Desktop.
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
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