Here you can find the source of removeNullValues(final Map
Parameter | Description |
---|---|
parameters | a parameter |
public static Map<String, String> removeNullValues(final Map<String, String> parameters)
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import java.util.Map; public class Main { /**//from w w w. j a va 2s . c o m * Removes Entries with null as value and returns a new Map * * @param parameters * @return new map with no null values */ public static Map<String, String> removeNullValues(final Map<String, String> parameters) { Map<String, String> cleanedParameters = new HashMap<>(parameters.size(), 1); for (Map.Entry<String, String> entry : parameters.entrySet()) { if (entry.getValue() != null) { cleanedParameters.put(entry.getKey(), entry.getValue()); } } return cleanedParameters; } }