Java Map Add addToListMap(Map> map, T key, T value)

Here you can find the source of addToListMap(Map> map, T key, T value)

Description

add To List Map

License

Open Source License

Declaration

public static <T> Map<T, List<T>> addToListMap(Map<T, List<T>> map, T key, T value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;
import java.util.Map;

public class Main {
    public static <T> Map<T, List<T>> addToListMap(Map<T, List<T>> map, T key, T value) {
        if (map == null)
            return null;
        if (key == null || value == null)
            return map;
        List<T> set = map.get(key);
        if (set == null)
            set = new ArrayList<T>();
        set.add(value);/*from w  w w .ja va  2 s.  co m*/
        map.put(key, set);
        return map;
    }
}

Related

  1. addToAnd(T target, Map... items)
  2. addToList(Map> map, X key, Y value)
  3. addToListMap(Map map, Object key, Object value)
  4. addToListMap(Map> map, K key, V value)
  5. addToListMap(Map> map, String key, String value)
  6. addToListMap(Map> map, T key, V val)
  7. addToListMap(Map> map, TKey key, TValue value)
  8. addToMap(Map map, int initialKey, T value)
  9. addToMap(Map data, K key, T value, Class clz)