Java List Value Add add(Map> multiValueMap, String key, Object value)

Here you can find the source of add(Map> multiValueMap, String key, Object value)

Description

add

License

Open Source License

Declaration

public static void add(Map<String, List<Object>> multiValueMap, String key, Object value) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    public static void add(Map<String, List<Object>> multiValueMap, String key, Object value) {
        put(multiValueMap, key, value, false);
    }/*  w  ww .j a v a 2  s  .  com*/

    private static void put(Map<String, List<Object>> multiValueMap, String key, Object value, boolean single) {
        synchronized (multiValueMap) {
            // save calling code some headaches
            if (value == null) {
                if (single)
                    multiValueMap.remove(key);
                return;
            }
            List<Object> values = multiValueMap.get(key);
            if (values == null) {
                values = new ArrayList<Object>();
                multiValueMap.put(key, values);
            } else if (single)
                values.clear();
            values.add(value);
        }
    }
}

Related

  1. add(List aList, T anObj)
  2. add(List aList, T anObject)
  3. add(List current, T toAdd)
  4. add(List list, int i, T v)
  5. add(List list, T element)
  6. add(Object o, List oldList)
  7. addElement(T element, List list)
  8. addElementIfAbsent(List l, T element)
  9. addElements(boolean removeDuplicates, final List result, Collection elements)