I need to store keys as case insensitive, and all values for keys like STATE/state/State are merged into one Set. However the catch is I need the case sensitive version of the original key back at some point so a generic CaseInsensitiveMap doesn't work. I only need back the first capitalization of 'state' added, so in this case I keep STATE and discard state/State.
I've looked at a few options for implementing this data structure, like Guava HashMultimap and Tuples, but none seem quite right.
<CaseInsensitiveOriginalKey, OriginalKey, Set<Values>>
So for example if I add a key 'State' with values {Texas, Oklahoma} it will be stored as:
<state, State, {Texas, Oklahoma}>
The idea being if I create some kind of .add(StATe, {Nebraska}) then the map, seeing a case-insensitive entry for 'state' already exists, becomes:
<state, State, {Texas, Oklahoma, Nebraska}>
and for a new key, .add(COLOR, {blue, red})
The overall map becomes:
<state, State, {Texas, Oklahoma, Nebraska}>
<color, COLOR, {blue, red}>
- .get(ColoR) returns {red, blue}
- .getKey(coLOR) returns COLOR
Any ideas on how to best accomplish this?