Enum with integer value
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
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