Guava's BiMap already provides a method for reversing its key-value pairs. Perhaps you could change the interface of the Map
in question to BiMap
, or else use the following code:
private BiMap reverseMap(Map permissions) {
BiMap bimap = HashBiMap.create(permissions);
return bimap.inverse();
}