Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Enum with integer value
public enum CardViewType {
SUBSCRIBED(1),
REJECTED(2),
NEW(3);
private int value;
private static Map<Integer, CardViewType> map = new HashMap<>();
CardViewType(int value) {
this.value = value;
}
static {
for (CardViewType type : CardViewType.values()) {
map.put(type.value, type);
}
}
public static CardViewType valueOf(int type) {
return map.get(type);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment