List of usage examples for java.util Map putAll
void putAll(Map<? extends K, ? extends V> m);
From source file:Main.java
/** * Returns a new <code>Map</code> instance which contains the given <code>sourceMap<code> * and <code>members<code> values. * * @param sourceMap map from which to copy entries into the result. * @param members additional entries to add. *///from w w w . j a va 2s. c o m public static Map<String, String> addAll(Map<String, String> sourceMap, String[][] members) { Map<String, String> result = new HashMap<String, String>(sourceMap); result.putAll(asMap(members)); return result; }
From source file:Main.java
/** * Parse a URL query and fragment parameters into a key-value bundle. * // www. j av a 2 s.c o m * @param url * the URL to parse * @return a dictionary bundle of keys and values */ public static Map<String, String> parseUrl(String url) { // hack to prevent MalformedURLException url = url.replace("fbconnect", "http"); try { URL u = new URL(url); Map<String, String> params = decodeUrl(u.getQuery()); params.putAll(decodeUrl(u.getRef())); return params; } catch (MalformedURLException e) { return new HashMap<String, String>(); } }
From source file:Main.java
/** * Join the two given maps to one by checking if one of the two maps already fulfills everything. Be aware that the * newly created collection is unmodifiable but will change if the underlying collections change! * * @param <K> The key type// www. j av a2 s. c o m * @param <V> The value type * @param first The first {@link Map} to join * @param second The second {@link Map} to join * * @return A {@link Map} with the joined content (can be one of the given map if the other is empty or null) */ public static <K, V> Map<K, V> joinMapUnmodifiable(Map<K, V> first, Map<K, V> second) { if (first == null || first.isEmpty()) { if (second == null || second.isEmpty()) { return Collections.emptyMap(); } else { return Collections.unmodifiableMap(second); } } else if (second == null || second.isEmpty()) { return Collections.unmodifiableMap(first); } else { Map<K, V> temp = new LinkedHashMap<K, V>(first.size() + second.size()); temp.putAll(first); temp.putAll(second); return Collections.unmodifiableMap(temp); } }
From source file:Main.java
@Nonnull public static <K, V> Map<K, V> putAll(@Nonnull Map<K, V> original, @Nullable Map<K, V> other) { if (other != null) { original.putAll(other); }/*from w w w . j a v a2s.com*/ return original; }
From source file:Main.java
public static Map<String, Object> merge(Map<String, Object>... maps) { Map<String, Object> ret = new LinkedHashMap<String, Object>(); for (Map<String, Object> map : maps) { ret.putAll(map); }/*from w w w . j a va 2 s . c o m*/ return ret; }
From source file:Main.java
/** * Adds all elements of the <code>src</code> collections to <code>dest</code>, * returning <code>dest</code>. This is typically used when you need to combine * collections temporarily for a method argument. * <p>/* w ww. j ava 2 s .c om*/ * Note: source maps are added in order; if the same keys are present in multiple * sources, the last one wins. * * @since 1.0.7 */ public static <K, V> Map<K, V> combine(Map<K, V> dest, Map<K, V>... src) { for (Map<K, V> cc : src) { dest.putAll(cc); } return dest; }
From source file:guru.bubl.module.model.validator.UserValidator.java
public static Map<String, String> errorsForUserAsJson(JSONObject user) { Map<String, String> errors = new LinkedHashMap<>(); errors.putAll(errorsForEmail(user.optString(UserJson.EMAIL))); errors.putAll(validateUserName(user.optString(UserJson.USER_NAME))); errors.putAll(errorsForPassword(user.optString(UserJson.PASSWORD))); return errors; }
From source file:net.eledge.android.europeana.search.model.record.abstracts.Resource.java
protected static Map<String, String[]> mergeMapArrays(Map<String, String[]> source1, Map<String, String[]> source2) { Map<String, String[]> merged = new HashMap<>(); if (source1 != null) { merged.putAll(source1); } else {//from w ww .j a v a2 s. c o m return source2; } if (source2 != null) { for (String key : source2.keySet()) { if (merged.containsKey(key)) { merged.put(key, mergeArray(merged.get(key), source2.get(key))); } else { merged.put(key, source2.get(key)); } } } return merged; }
From source file:io.cloudslang.lang.entities.utils.MapUtils.java
private static void putAllIfNotEmpty(Map<String, Value> target, Map<String, Value> source) { if (org.apache.commons.collections4.MapUtils.isNotEmpty(source)) { target.putAll(source); }//from w w w. j a v a 2 s . c o m }
From source file:fr.itldev.koya.webscript.KoyaWebscript.java
/** * Extracts URL paramters.//from w w w.ja va2 s . c o m * * * @param req * @return */ public static Map<String, String> getUrlParamsMap(WebScriptRequest req) { Map<String, String> params = new HashMap<>(); params.putAll(req.getServiceMatch().getTemplateVars()); for (String k : req.getParameterNames()) { String param; try { /** * Decode double encoded url parameter : ex string with accent * characters * * TODO charset permissive implementation */ param = new String(req.getParameter(k).getBytes("iso-8859-1"), "UTF-8"); } catch (UnsupportedEncodingException ex) { param = req.getParameter(k); LOGGER.error(ex.getMessage(), ex); } params.put(k, param); } return params; }