ctor.setAccessible(true);
item = ctor.newInstance();
} catch (Exception e) {
throw new IllegalArgumentException("Cannot instantiate " + clazz.getName(), e);
}
DefinitionElement de = clazz.getAnnotation(DefinitionElement.class);
if (definition instanceof ComplexDefinition) {
if (de.resolveType() == DefinitionElement.ResolveType.PASS_BY_MAP) {
PropertyHelper.setPropertiesFromDefinitions(item, ((ComplexDefinition) definition).getAttributeMap(), false, true);
} else if (de.resolveType() == DefinitionElement.ResolveType.PASS_BY_DEFINITION) {
PropertyHelper.setPropertiesFromDefinitions(item, Collections.singletonMap("", definition), false, true);
} else throw new IllegalStateException(de.resolveType().toString());
} else if (definition instanceof SimpleDefinition) {
PropertyHelper.setProperties(item, Collections.singletonMap("", ((SimpleDefinition) definition).value), false, true);
}
return item;
}