Java Map Clone cloneMap(final Map m)

Here you can find the source of cloneMap(final Map m)

Description

clone Map

License

Open Source License

Declaration

private static Map<String, Object> cloneMap(final Map<String, Object> m) 

Method Source Code

//package com.java2s;
/*//w ww.ja  v a2 s . c o m
 *  Copyright (C) 2010 vektor
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.HashMap;

import java.util.Map;
import java.util.Map.Entry;

public class Main {
    private static Map<String, Object> cloneMap(final Map<String, Object> m) {
        if (m == null) {
            return null;
        }
        final Map<String, Object> ret = new HashMap<String, Object>(m.size());
        for (final Entry<String, Object> e : m.entrySet()) {
            // not a true clone, though :-(
            ret.put(String.valueOf(e.getKey()), e.getValue());
        }
        return ret;
    }
}

Related

  1. clone(Map configurationValues)
  2. clone(Map map1)
  3. clone(Map origMap)
  4. clone(Map map)
  5. cloneDefaults(Map defaults)
  6. cloneMap(Map map)
  7. cloneMap(Map orig)
  8. cloneMap(Map> map)