Skip to content

Instantly share code, notes, and snippets.

@pastelHex
Last active December 1, 2020 09:34
Show Gist options
  • Save pastelHex/e673de4401b544e94079f280419b90ad to your computer and use it in GitHub Desktop.
Save pastelHex/e673de4401b544e94079f280419b90ad to your computer and use it in GitHub Desktop.
import java.util.HashMap;
public enum EnumMap {
E1(1),
E2(2),
E3(3),
E4(4);
private int value;
public static HashMap<Integer, EnumMap> extensionMap;
private EnumMap(int i) {
this.value = i;
this.addToExtension(i);
}
public static EnumMap findByKey(int i) {
return (EnumMap)extensionMap.get(i);
}
private void addToExtension(int i) {
if (extensionMap == null) {
extensionMap = new HashMap();
}
extensionMap.put(i, this);
}
public int getValue() {
return this.value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment