Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9269115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:01:55+00:00 2026-06-18T15:01:55+00:00

I have the following BiMap collections: BiMap<String,String> accessIds = HashBiMap.create(); accessIds.put(FOO,accessId 1); //This access

  • 0

I have the following BiMap collections:

BiMap<String,String> accessIds = HashBiMap.create();
accessIds.put("FOO","accessId 1"); //This access Id is common to both FOO and BAR

BiMap<String,String> merchants = HashBiMap.create();
merchants.put("FOO", "merchant 1"); //Both FOO and BAR each have unique merchants
merchants.put("BAR", "merchant 2");

These are 2 of the 4 total collections I currently have. All 4 collections share the same keys, but different values.

The question I have is: How can I ensure that I can get merchant 2 when I have an accessIds key of FOO?

Before someone points out that these two collections do not, in fact, share the same keys, please remember that a BiMap enforces unique values so I am unable to list "BAR","accessId 1" in the collection.

I’m not convinced that BiMap is the right collection, but I do make use of its inverse() method. If there is a collection better suited ( or some other method that I am overlooking ) please let me know.

FYI: I use Guava-14.0-rc1 for the BiMap collection.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:01:57+00:00Added an answer on June 18, 2026 at 3:01 pm

    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 Maps (or BiMaps, though it’s unclear through your example why they are BiMaps, 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().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following .ashx page that takes some query string parameters and returns
I have the following code. QString fileName = QFileDialog::getSaveFileName( this, tr(Output Image file), (),
I have the following code; String[] projection = { MediaStore.Video.VideoColumns._ID, MediaStore.Video.VideoColumns.DATA }; //String selection
I have the following function inside my WCF service. This function is used to
I have the following code in a CDialog. This code works perfectly on Windows
I have the following code in a drawable bitmap xml file. And the background
I have the exercise with following code int FindFirstSet(unsigned BitMap, unsigned start) { unsigned
I have following plist: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd>
I have following source. In insertMessage(..), it calls selectMessage to check whether duplicate record
I have following div in a page (I can not modify). <div id=:0.control>Click me</div>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.