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

  • Home
  • SEARCH
  • 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 8172337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:45:20+00:00 2026-06-06T21:45:20+00:00

I have the following data structure for the entity relationships: Map<Integer, Map<Integer, Map<PAXType, BigDecimal>>>

  • 0

I have the following data structure for the entity relationships:

Map<Integer, Map<Integer, Map<PAXType, BigDecimal>>>

Entity Relationships:

  • 1 Package(P) has Many Variants(V)
  • 1 Variants(V) has Many Price data-points
  • Price is based on the PAXType (which is an enum: Adult, Child, Infant)

I modelled this using:

Map<Package, Map<Variant, Map<PAXType, BigDecimal>>>

for the purpose of quick price lookup based on

  • package
  • package variant

The way I’m using this right now is:
As I read data from the db, I create/update the above map. After I get all the info, for each variant, I need to transform the price map, from Map<PAXType, BigDecimal> to Map<OccupancyType, BigDecimal>, where OccupancyType is another enum. This is the final price format which I need to output for serialization etc.

Is there any data structure in guava which would be a good fit for the ugly map construct I have and support the operations I suggested above ?

  • 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-06T21:45:22+00:00Added an answer on June 6, 2026 at 9:45 pm

    In addition to Tomasz’s answer suggesting encapsulating Map<PAXType, BigDecimal> in class PriceByType (note that if PAXType is an enum, you should use EnumMap) I think you should consider using Guava’s Table as substitution for Map<Integer, Map<Integer, PriceByType>>. Table use case:

    Typically, when you are trying to index on more than one key at a
    time, you will wind up with something like Map<FirstName,
    Map<LastName, Person>>
    , which is ugly and awkward to use. Guava
    provides a new collection type, Table, which supports this use case
    for any “row” type and “column” type.

    Your indexes are package and package variant, both Integers, so table should end up with Table<Integer, Integer, PriceByType>.

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

Sidebar

Related Questions

I have the following data set structure: date time_in_hours price Sep 03 08 9.76
I have the following data structure: One ModelA has a nested collection of ModelBs.
I have following data structure (simplified): A giant list of the class TestClass public
I have the following data structure: P_ID EVSSMIN EVSSMAX TDMIN TDMAX WARD SYRINGE_ID COMBINE_WITH
I have the following data structure (an atomic vector?) output from daply in plyr
I have the following JavaScript data structure. a[] is an array with text strings
I have something like the following data structure: Category StartDateTime EndDateTime =============================================== 1 12/1/2009
I have an odd linq subquery issue. Given the following data structure: Parents Children
I have the following casting problem when my data structure sSpecificData contains a field
Let's assume I have the following file structure: data.py foo = [] bar =

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.