Java Map Put putMapNotNullKey(Map map, K key, V value)

Here you can find the source of putMapNotNullKey(Map map, K key, V value)

Description

add key-value pair to map, key need not null

License

Apache License

Parameter

Parameter Description
map a parameter
key a parameter
value a parameter

Return

  • if map is null, return false
  • if key is null, return false
  • return

Declaration

public static <K, V> boolean putMapNotNullKey(Map<K, V> map, K key, V value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Map;

public class Main {
    /**//from  w  w  w  .ja  v a  2s. co m
     * add key-value pair to map, key need not null
     * 
     * @param map
     * @param key
     * @param value
     * @return <ul>
     *         <li>if map is null, return false</li>
     *         <li>if key is null, return false</li>
     *         <li>return {@link Map#put(Object, Object)}</li>
     *         </ul>
     */
    public static <K, V> boolean putMapNotNullKey(Map<K, V> map, K key, V value) {
        if (map == null || key == null) {
            return false;
        }

        map.put(key, value);
        return true;
    }
}

Related

  1. putMap(Map target, Map map)
  2. putMapBoolean(Map params, String key)
  3. putMapBooleanList(Map params, String... keys)
  4. putMapByPair(String pair, Map m)
  5. putMapEntry(Map map, String name, String value)
  6. putMapValue(String path, Object value, Map map)
  7. putModifiedAttribute(Map aMap, String name, Object value)
  8. putMultiEntry(Map map, Iterable keys, V value)
  9. putMultiple(Map map, Object key, Object value)