@SuppressWarnings("unchecked") public static <E>void transformStringCollection(Collection<String> original,Collection<E> collection,Class<E> elementClass) throws PreferenceException {
  Method parseMethod=findParseMethod(elementClass);
  if (null != parseMethod) {
    for (    String toTransform : original) {
      try {
        Object transformed=parseMethod.invoke(null,toTransform);
        if (elementClass.isAssignableFrom(transformed.getClass())) {
          collection.add((E)transformed);
        }
      }
 catch (      Exception e) {
        throw new PreferenceException("Error transforming Collection<java.lang.String> to Collection<" + elementClass.getName() + ">.",e);
      }
    }
  }
 else {
    throw new PreferenceException("Error transforming Collection<java.lang.String> to Collection<" + elementClass.getName() + ">. Parsing method can not be found in class "+ elementClass.getName()+ ".");
  }
}

@ SuppressWarnings ( "unchecked" ) public static < E > void transformStringCollection ( Collection < String > original , Collection < E > collection , Class < E > elementClass ) throws PreferenceException { Method parseMethod = findParseMethod ( elementClass ) ; if ( null != parseMethod ) { for ( String toTransform : original ) { try { Object transformed = parseMethod . invoke ( null , toTransform ) ; if ( elementClass . isAssignableFrom ( transformed . getClass ( ) ) ) { collection . add ( ( E ) transformed ) ; } } catch ( Exception e ) { throw new PreferenceException ( "Error transforming Collection<java.lang.String> to Collection<" + elementClass . getName ( ) + ">." , e ) ; } } } else { throw new PreferenceException ( "Error transforming Collection<java.lang.String> to Collection<" + elementClass . getName ( ) + ">. Parsing method can not be found in class " + elementClass . getName ( ) + "." ) ; } }
transforms all the strings in the original collection to the given class objects and adds them to the given resulting collection .
