public static <K extends Object,V extends Object>boolean addToListMap(Map<K,List<V>> map,K key,V value){
  if (map == null) {
    return false;
  }
  List<V> list=map.get(key);
  if (list == null) {
    list=new ArrayList<V>();
    map.put(key,list);
  }
  if (!list.contains(value)) {
    list.add(value);
    return true;
  }
  return false;
}

public static < K extends Object , V extends Object > boolean addToListMap ( Map < K , List < V > > map , K key , V value ) { if ( map == null ) { return false ; } List < V > list = map . get ( key ) ; if ( list == null ) { list = new ArrayList < V > ( ) ; map . put ( key , list ) ; } if ( ! list . contains ( value ) ) { list . add ( value ) ; return true ; } return false ; }
populated a ( key , value ) pair in a map of lists . it finds the list at key and adds value to the list . if there is no list at key , create a new list and add it to the map .
