Java Map Copy copyMap(Object object)

Here you can find the source of copyMap(Object object)

Description

copy Map

License

LGPL

Declaration

@Deprecated
public static Map<String, Object> copyMap(Object object) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.util.HashMap;

import java.util.Map;

public class Main {
    /**//from ww w. ja va2 s .com
     * @deprecated 20160907 hsilva: not seeing any method using it, so it will be
     *             removed soon
     */
    @Deprecated
    public static Map<String, Object> copyMap(Object object) {
        if (!(object instanceof Map)) {
            return null;
        }
        Map<?, ?> map = (Map<?, ?>) object;
        Map<String, Object> temp = new HashMap<>();
        for (Map.Entry<?, ?> entry : map.entrySet()) {
            if (entry.getKey() instanceof String) {
                temp.put((String) entry.getKey(), entry.getValue());
            } else {
                return null;
            }
        }
        return temp;
    }
}

Related

  1. copyMap(Map m)
  2. copyMap(Map m)
  3. copyMap(Map oMap)
  4. copyMap(Map map)
  5. copyMap(Map m)
  6. copyMapButFailOnNull(Map entries)
  7. copyMapWithoutEmpties(Map original)
  8. copyOf( Map> map)
  9. copyOf(final Map map)