// e.g., in other config extensions
if (providedConfObj == null) {
try {
confObj = (T) clazz.newInstance();
} catch (Exception e) {
throw new ConfigurationException("Error while instantiating config class " + clazz.getSimpleName()
+ ". Check whether null-arg constructor exists.", e);
}
} else
confObj = providedConfObj;
for (Field classField : clazz.getDeclaredFields()) {
// if field is not annotated, skip it
ConfigField fieldAnno = (ConfigField) classField.getAnnotation(ConfigField.class);
if (fieldAnno == null)
continue;
// find typeadapter
ConfigTypeAdapter customRep = config.lookupTypeAdapter(classField.getType());
if (customRep != null) {
try {
Object value = customRep.deserialize(serialized.get(fieldAnno.name()), config, classField);
// set using a setter, exception is when failIfNotPresent is false and there were no value
if (value != null || fieldAnno.failIfNotPresent())
PropertyUtils.setSimpleProperty(confObj, classField.getName(), value);
} catch (Exception e) {
throw new ConfigurationException("Error while reading configuration field " + fieldAnno.name(), e);
}
} else
throw new ConfigurationException("Corresponding 'reader' was not found for field " + fieldAnno.name());
}
return confObj;