try {
Constructor<T> constructor = destinationClass.getDeclaredConstructor();
constructor.setAccessible( true );
return constructor.newInstance();
} catch( NoSuchMethodException exception ) {
throw new TranslationException(
"No no-argument constructor in class "
+ destinationClass.getName(), exception );
} catch( InstantiationException exception ) {
throw new TranslationException( String.format(
"Error while instantiating %s", destinationClass ),
exception );
} catch( IllegalAccessException exception ) {
throw new TranslationException( String.format(
"Not allowed to instantiate %s", destinationClass ),
exception );
} catch( IllegalArgumentException exception ) {
throw new TranslationException( String.format(
"Error while instantiating %s", destinationClass ),
exception );
} catch( InvocationTargetException exception ) {
throw new TranslationException( String.format(
"Error thrown by constructor of %s", destinationClass ),
exception );
}
}