Based on your comment, in your workflow, the Access ID is a key, not a value, that in at least one case has several associated values instead of one.
You could use a Multimap
for your Access IDS, assuming you can then select which value to retain as the key for accessing the other Map
s (or BiMap
s, though it's unclear through your example why they are BiMap
s, but I guess that's unrelated).
ImmutableMultimap.Builder<String, String> builder = ImmutableMultimap.builder();
builder.put("FOO", "accessId 1");
builder.put("BAR", "accessId 1");
ImmutableMultimap<String, String> accessIds = builder.build();
ImmutableMultimap<String, String> byAccessIds = accessIds.inverse();
Collection<String> keys = byAccessIds.get("accessId 1"); // ["FOO", "BAR"]
String key = doSomething(keys); // "BAR" is chosen
String merchant = merchants.get(key); // "merchant 2"
If you cannot use immutable structures, you can also build a regular Multimap
for accessIds
(for example using a HashMultimap
) and inverse it using Multimaps.invertFrom()
.