I have a MultiValueMap<Integer, Path>
from which I am trying to get [print for the purpose of this question] out all the paths which were put in the map using the same key.
This is my current solution:
MultiValueMap<Integer, Path> duplicates = duplicateFinder.getDuplicates();
for (Map.Entry<Integer, Object> entry: duplicates.entrySet()) {
final Integer key = entry.getKey();
final Object obj = entry.getValue();
for (Object o: (LinkedList)((ArrayList)entry.getValue()).get(0))
System.out.println(o);
System.out.println();
}
I feel my solution is dangerous (casting and magic number 0) and would like to avoid it. How can I achieve the desired result in a more readable/safe manner?