Java Map Clone clone(Map configurationValues)

Here you can find the source of clone(Map configurationValues)

Description

Make a clone of the configuration values.

License

LGPL

Parameter

Parameter Description
configurationValues The config values to clone

Return

The clone

Declaration

@SuppressWarnings({ "unchecked" })
public static Map clone(Map<?, ?> configurationValues) 

Method Source Code


//package com.java2s;
/*//from ww w .  ja v  a2 s .c o m
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
 */

import java.util.HashMap;

import java.util.Map;
import java.util.Properties;

public class Main {
    /**
     * Make a clone of the configuration values.
     *
     * @param configurationValues The config values to clone
     *
     * @return The clone
     */
    @SuppressWarnings({ "unchecked" })
    public static Map clone(Map<?, ?> configurationValues) {
        if (configurationValues == null) {
            return null;
        }
        // If a Properties object, leverage its clone() impl
        if (Properties.class.isInstance(configurationValues)) {
            return (Properties) ((Properties) configurationValues).clone();
        }
        // Otherwise make a manual copy
        HashMap clone = new HashMap();
        for (Map.Entry entry : configurationValues.entrySet()) {
            clone.put(entry.getKey(), entry.getValue());
        }
        return clone;
    }
}

Related

  1. clone(Map aMap)
  2. clone(Map from, Map to)
  3. clone(Map map1)
  4. clone(Map origMap)
  5. clone(Map map)
  6. cloneDefaults(Map defaults)