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

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

Description

put If Not Null

License

Apache License

Parameter

Parameter Description
map a parameter
key a parameter
value a parameter

Declaration

public static <K, V> void putIfNotNull(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 {
    /**//w w  w.j  a va 2 s.  c  o m
     * 
     * @param map
     * @param key
     * @param value
     */
    public static <K, V> void putIfNotNull(Map<K, V> map, K key, V value) {
        if (map != null && key != null && value != null)
            map.put(key, value);
    }
}

Related

  1. putIfNonNull(Map map, K key, V value)
  2. putIfNotExist(Map map, K key, V value)
  3. putIfNotExists(final K key, final V value, final Map map)
  4. putIfNotExists(Map map, K key, V value)
  5. putIfNotNull(final Map map, final String name, final String value)
  6. putIfNotNull(Map> params, String key, T value)
  7. putIfNotNullAndTrue(Map map, String key, Boolean boolValue)
  8. putIfNull(Map map, Object key, Object defaultValue)
  9. putIfSet(Map config, String key, Object... values)