You might consider using Guava BiMap , such as HashBiMap . From the documentation:
A bimap (or "bi-directional map") is a map that preserves the uniqueness of its values, as well as its keys. This limitation allows bimaks to support "reverse lookup", which is another bimap containing the same entries as this bimap, but with reverse keys and values.
Thus, with a BiMap<Foo, Bar> you can call inverse() to return the view BiMap<Bar, Foo> .
source share