if (constructor != null) {
try {
target = constructor.newInstance(source);
}
catch (IllegalArgumentException ex) {
throw new ConversionFailedException(sourceType, targetType, source, ex);
}
catch (InstantiationException ex) {
throw new ConversionFailedException(sourceType, targetType, source, ex);
}
catch (IllegalAccessException ex) {
throw new ConversionFailedException(sourceType, targetType, source, ex);
}
catch (InvocationTargetException ex) {
throw new ConversionFailedException(sourceType, targetType, source, ex);
}
}
else {
throw new IllegalStateException("No static valueOf(" + sourceClass.getName() +
") method or Constructor(" + sourceClass.getName() + ") exists on " + targetClass.getName());