0

This there any efficient collection to associate a key with multiple values, something like

new HashMap<K,V,V>();

example:

 new HashMap<Long, List<CustomerVO>, List<FacilityInfo>>();

Thanks in advance!

Igor Zinov'yev
  • 3,606
  • 1
  • 31
  • 49

2 Answers2

5

Have a look at Apache Commons Multimap - it seems to be what you're after:

MultiMap mhm = new MultiHashMap();
mhm.put(key, "A");
mhm.put(key, "B");
mhm.put(key, "C");
Collection coll = (Collection) mhm.get(key);

Alternatively, you can just stick a collection of any kind into a regular map, e.g:

Map<Key, Set<Value>> myMap;
Aleks G
  • 54,795
  • 26
  • 160
  • 252
2

How about Plain Old Java Object approach -

public class CutomerFacilityDetail{
   List<CustomerVO> customvoList;
   List<FacilityInfo> facilityInfoList;
   ...<getter & setter method>
}

Now create map -Map<Long,List<CutomerFacilityDetail>>

Subhrajyoti Majumder
  • 39,719
  • 12
  • 74
  • 101