valueOf.setAccessible(true);
}
// Invoke the static method
return valueOf.invoke(null, new String[] {strValue});
} catch (InvocationTargetException e) {
throw new ConfigurationException("Cannot create an enumerated value for " + type
+ " with " + strValue, e.getTargetException());
} catch (Exception e) {
throw new ConfigurationException("Cannot create an enumerated value for " + type
+ " with " + strValue, e);
}
}
// Else it is a neither a primitive type neither a String -> create
// the object by calling a constructor with a string in argument.
try {
Constructor cst = type.getConstructor(new Class[] { String.class });
return cst.newInstance(new Object[] { strValue });
} catch (SecurityException e) {
throw new ConfigurationException("Security exception during the creation of " + type, e);
} catch (NoSuchMethodException e) {
throw new ConfigurationException("Constructor not found exception during the creation of " + type, e);
} catch (IllegalArgumentException e) {
throw new ConfigurationException("Argument issue when calling the constructor of the type " + type, e);
} catch (InstantiationException e) {
throw new ConfigurationException("Instantiation problem " + type, e);
} catch (IllegalAccessException e) {
throw new ConfigurationException("Illegal Access " + type, e);
} catch (InvocationTargetException e) {
throw new ConfigurationException("Invocation problem during the creation of " + type, e.getTargetException());
}
}