Java List Add put(Map> multiValueMap, String key, Object value, boolean single)

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

Description

put

License

Open Source License

Declaration

private static void put(Map<String, List<Object>> multiValueMap, String key, Object value, boolean single) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    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;
            }// ww  w  .j  a va  2  s  .  c  o  m
            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);
        }
    }

    public static void add(Map<String, List<Object>> multiValueMap, String key, Object value) {
        put(multiValueMap, key, value, false);
    }
}

Related

  1. put(List list, int[] values)
  2. put(List list, Object object)

    HOME | Copyright © www.java2s.com 2016