Guava supplies an inversion method for Multimap
. See Multimaps.invertFrom.
This might do fine for you if you don't frequently need the inversion, or if your multimap is small. But this inversion is an expensive process. You can likely gain some efficiency by simply maintaining both forward and reverse as suggested by JB Nizet in comments. Both however can be multimaps to allow for non-uniqueness.