Is there a more elegant/built-in way to reverse the keys and values of a Hashmap?
I currently have the following.
private Map
I'd do something similar (but if you must do this kind of thing frequently, consider Guava), only replacing the List with Set (seems a little more consistent) and prefilling the reversemap:
private Map> reverseMap(Map permissions) {
Map> returnvalue = new HashMap>();
returnvalue.put(Boolean.TRUE, new HashSet());
returnvalue.put(Boolean.FALSE, new HashSet());
for (Entry entry : permissions.entrySet())
returnvalue.get(entry.getValue()).add(entry.getKey());
return returnvalue;
}