Il est parfois utile de stocker les valeurs de l'enum dans une carte statique :
public static HashMap<NotificationTypes, Integer> getIntValueMap()
{
if (null == st_map)
{
st_map = new HashMap<NotificationTypes, Integer>();
st_map.put(NotificationTypes.NT_MemberSentMessage, 0);
st_map.put(NotificationTypes.NT_NewFollower, 1);
st_map.put(NotificationTypes.NT_LikeSomethingNearby, 2);
st_map.put(NotificationTypes.NT_MemberLikesCreatorsExp, 3);
st_map.put(NotificationTypes.NT_MemberLikesPlacePostersExp, 4);
st_map.put(NotificationTypes.NT_MemberCreatesExpAtPlacePoster, 5);
st_map.put(NotificationTypes.NT_FollowerHasPosted, 6);
st_map.put(NotificationTypes.NT_FollowerHasLiked, 7);
st_map.put(NotificationTypes.NT_NearbyHasJoined, 8);
st_map.put(NotificationTypes.NT_NearbyHasPosted, 9);
st_map.put(NotificationTypes.NT_NearbyHasLiked, 10);
st_map.put(NotificationTypes.NT_NewClientAvailable, 11);
st_map.put(NotificationTypes.NT_UnreadMessageUpdate, 12);
st_map.put(NotificationTypes.NT_MemberStatusIncreased, 13);
st_map.put(NotificationTypes.NT_BulkFollowers, 14);
st_map.put(NotificationTypes.NT_BulkFollowersExpert, 15);
st_map.put(NotificationTypes.NT_DefaultFollowing, 16);
st_map.put(NotificationTypes.NT_PromptToAddExperience, 17);
st_map.put(NotificationTypes.NT_MemberCommentedMembersExp, 18);
st_map.put(NotificationTypes.NT_MemberCommentedOnMembersComment, 19);
}
return st_map;
}
1 votes
Duplicata possible de Comment faire correspondre int à enum