Java Map Copy copy(Map src, Map propertyRef)

Here you can find the source of copy(Map src, Map propertyRef)

Description

copy

License

Apache License

Declaration

public static Map<?, ?> copy(Map<?, ?> src, Map<?, ?> propertyRef) 

Method Source Code


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

import java.util.HashMap;

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

public class Main {

    public static Map<?, ?> copy(Map<?, ?> src, Map<?, ?> propertyRef) {
        Map<Object, Object> dst = new HashMap<Object, Object>();

        Set<?> entrySet = src.entrySet();
        for (Object object : entrySet) {
            if (object != null && object instanceof Entry<?, ?>) {
                Entry<?, ?> entry = (Entry<?, ?>) object;
                Object key = entry.getKey();
                Object value = entry.getValue();

                if (key != null) {
                    Object refKey = propertyRef.get(key);
                    if (refKey != null) {
                        dst.put(refKey, value);
                    }/*from  w  w  w .  j a  va  2s .  co m*/
                }
            }
        }

        return dst;

    }
}

Related

  1. copy(final Map source)
  2. copy(Map dest, Map src)
  3. copy(Map master, Map slave)
  4. copy(Map to, Map from, Object keys[])
  5. copy(Map> original)
  6. copy(Map map)
  7. copy(Map master, Map copy)
  8. copy(Map> original)