I have a map of values. The values are limited to just 3 possibilities ( "A", "B", "C") . I will have some 100 entries for this map.
Map<String, String> map = new HashMap<>();
map.put("key1","A");
map.put("key2","B");
map.put("key3","C");
map.put("key4","A");
map.put("key5","B");
.
.
.
The only purpose of this map would be a function where I get the key as input and I need to return one of the three "A","B","C" or null if the key has no value. My lookup will only be based on the key here.
I cannot decide if I should repeat the values and construct a flat map as above, or to use a Map<String, List<String>>
where the key would be the three values. As in
Map<String, List<String>> map = new HashMap<>();
map.put("A",Arrays.asList("key1","key2"));
map.put("B",Arrays.asList("key3","key4"));
map.put("C",Arrays.asList("key5","key6"));
Or, do I use 3 separate List<String>
variables and check using contains each time. As in
List<String> A_LIST = Arrays.asList("key1","key2");
List<String> B_LIST = Arrays.asList("key3","key4");
List<String> C_LIST = Arrays.asList("key5","key6");
Also, do I use an enum/static Strings for the values here and repeat them while constructing the Map? What would be the proper way to do this? Any advice would be useful.