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,676
  • 1
  • 33
  • 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
  • 56,435
  • 29
  • 168
  • 265
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
  • 40,646
  • 13
  • 77
  • 103