Here you can find the source of putIfNotNull(Map
Parameter | Description |
---|---|
params | a parameter |
key | a parameter |
value | a parameter |
public static <T> void putIfNotNull(Map<String, Collection<String>> params, String key, T value)
//package com.java2s; //License from project: LGPL import java.util.Collection; import java.util.Collections; import java.util.Map; public class Main { /**/*w w w . j a va 2 s . co m*/ * put value in map only if not null * * @param params * @param key * @param value */ public static <T> void putIfNotNull(Map<String, Collection<String>> params, String key, T value) { if (value != null) { params.put(key, Collections.singleton(String.valueOf(value))); } } }