@SuppressWarnings("unchecked") public static <K,V>void transformStringMap(Map<String,String> original,Map<K,V> map,Class<K> keyClass,Class<V> valueClass) throws PreferenceException {
  Method parseKeyMethod=findParseMethod(keyClass);
  Method parseValueMethod=findParseMethod(valueClass);
  if ((null != parseKeyMethod) && (null != parseValueMethod)) {
    for (    Map.Entry<String,String> toTransformEntry : original.entrySet()) {
      try {
        Object transformedKey=parseKeyMethod.invoke(null,toTransformEntry.getKey());
        Object transformedValue=parseValueMethod.invoke(null,toTransformEntry.getValue());
        if (keyClass.isAssignableFrom(transformedKey.getClass()) && valueClass.isAssignableFrom(transformedValue.getClass())) {
          map.put((K)transformedKey,(V)transformedValue);
        }
      }
 catch (      Exception e) {
        throw new PreferenceException("Error transforming Map<java.lang.String, java.lang.String> to Map<" + keyClass.getName() + ", "+ valueClass.getName()+ ">.",e);
      }
    }
  }
 else   if (null == parseKeyMethod) {
    throw new PreferenceException("Error transforming Map<java.lang.String, java.lang.String> to Map<" + keyClass.getName() + ", "+ valueClass.getName()+ ">."+ "Parsing method can not be found in class "+ keyClass.getName()+ ".");
  }
 else {
    throw new PreferenceException("Error transforming Map<java.lang.String, java.lang.String> to Map<" + keyClass.getName() + ", "+ valueClass.getName()+ ">."+ "Parsing method can not be found in class "+ valueClass.getName()+ ".");
  }
}

@ SuppressWarnings ( "unchecked" ) public static < K , V > void transformStringMap ( Map < String , String > original , Map < K , V > map , Class < K > keyClass , Class < V > valueClass ) throws PreferenceException { Method parseKeyMethod = findParseMethod ( keyClass ) ; Method parseValueMethod = findParseMethod ( valueClass ) ; if ( ( null != parseKeyMethod ) && ( null != parseValueMethod ) ) { for ( Map . Entry < String , String > toTransformEntry : original . entrySet ( ) ) { try { Object transformedKey = parseKeyMethod . invoke ( null , toTransformEntry . getKey ( ) ) ; Object transformedValue = parseValueMethod . invoke ( null , toTransformEntry . getValue ( ) ) ; if ( keyClass . isAssignableFrom ( transformedKey . getClass ( ) ) && valueClass . isAssignableFrom ( transformedValue . getClass ( ) ) ) { map . put ( ( K ) transformedKey , ( V ) transformedValue ) ; } } catch ( Exception e ) { throw new PreferenceException ( "Error transforming Map<java.lang.String, java.lang.String> to Map<" + keyClass . getName ( ) + ", " + valueClass . getName ( ) + ">." , e ) ; } } } else if ( null == parseKeyMethod ) { throw new PreferenceException ( "Error transforming Map<java.lang.String, java.lang.String> to Map<" + keyClass . getName ( ) + ", " + valueClass . getName ( ) + ">." + "Parsing method can not be found in class " + keyClass . getName ( ) + "." ) ; } else { throw new PreferenceException ( "Error transforming Map<java.lang.String, java.lang.String> to Map<" + keyClass . getName ( ) + ", " + valueClass . getName ( ) + ">." + "Parsing method can not be found in class " + valueClass . getName ( ) + "." ) ; } }
transforms all the strings key / value pairs in the original map to the given class key / value pairs and adds them to the given resulting map .
