public static < K , V > Map < K , V > copy ( final Map < K , V > map ) { if ( map == null ) { return null ; } TypeEnum keyType = null ; TypeEnum valueType = null ; Map < K , V > copy = new HashMap < K , V > ( ) ; for ( Map . Entry < K , V > entry : map . entrySet ( ) ) { K key = entry . getKey ( ) ; V value = entry . getValue ( ) ; K keyCopy = null ; if ( key != null ) { if ( keyType == null ) { keyType = TypeEnum . dataTypeOf ( key . getClass ( ) ) ; } keyCopy = copy ( key , keyType ) ; } V valueCopy = null ; if ( value != null ) { if ( valueType == null ) { valueType = TypeEnum . dataTypeOf ( value . getClass ( ) ) ; } valueCopy = copy ( value , valueType ) ; } copy . put ( keyCopy , valueCopy ) ; } return copy ; }
Returns a deep copy of a pdef map .