Here you can find the source of putAll(final Map
Parameter | Description |
---|---|
dst | the destination Map |
src | the source Map |
K | the source key type |
V | the source value type |
public final static <K, V> void putAll(final Map<String, String> dst, final Map<K, V> src)
//package com.java2s; /**/* ww w .ja v a 2 s. co m*/ * The contents of this file are subject to the Regenstrief Public License * Version 1.0 (the "License"); you may not use this file except in compliance with the License. * Please contact Regenstrief Institute if you would like to obtain a copy of the license. * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * Copyright (C) Regenstrief Institute. All Rights Reserved. */ import java.util.*; import java.util.Map.Entry; public class Main { /** * Put all entries from the source Map into the destination Map, converting keys and values to * Strings if needed * * @param dst the destination Map * @param src the source Map * @param <K> the source key type * @param <V> the source value type **/ public final static <K, V> void putAll(final Map<String, String> dst, final Map<K, V> src) { final Iterator<Entry<K, V>> iter = src.entrySet().iterator(); while (iter.hasNext()) { final Entry<K, V> entry = iter.next(); dst.put(toString(entry.getKey()), toString(entry.getValue())); } } public final static <E> Iterator<E> iterator(final Iterable<E> iterable) { return iterable == null ? null : iterable.iterator(); } public final static boolean hasNext(final Iterator<?> i) { return (i != null) && i.hasNext(); } /** * Converts an object to a string * * @param o the Object to convert * @return the String **/ public final static String toString(final Object o) { return o == null ? null : o.toString(); } }