Java Map Add addToMapIfNotNull(Map map, String key, Object value)

Here you can find the source of addToMapIfNotNull(Map map, String key, Object value)

Description

add To Map If Not Null

License

LGPL

Declaration

public static void addToMapIfNotNull(Map<String, Object> map, String key, Object value) 

Method Source Code

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

import java.util.Map;

public class Main {
    public static void addToMapIfNotNull(Map<String, Object> map, String key, Object value) {
        addToMapIfNotNull(map, key, value, "");
    }/*from   ww  w  .ja  v  a  2 s.  co  m*/

    public static void addToMapIfNotNull(Map<String, Object> map, String key, Object value, String keyPrefix) {
        if (keyPrefix == null)
            keyPrefix = "";
        if (key != null && value != null)
            map.put(keyPrefix + key, value);
    }
}

Related

  1. addToMap(Map aMap, T aKey, Float aValue)
  2. addToMap(Map map, T item)
  3. addToMap(String aDimensionCriteria, Map aDrilldownDimensions)
  4. addToMap(String key, Map map, String value)
  5. addToMapIfNotNull(Map map, K key, V value)
  6. addToMapListUnique(Map> mapList, T key, List values)
  7. addToMapMap(Map> map, K1 key1, K2 key2, V value)
  8. addToMapMap(Map> map, T key, V val)
  9. addToMapOfLists(Map> map, S key, T value)