// (e.g. by applying <properties> tag).
delegate.mapToEntityFromMap(verCfg, obj, data, primaryKey, versionsReader, revision);
return;
}
Setter setter = ReflectionTools.getSetter(obj.getClass(), propertyData);
// If all properties are null and single, then the component has to be null also.
boolean allNullAndSingle = true;
for (Map.Entry<PropertyData, PropertyMapper> property : delegate.getProperties().entrySet()) {
if (data.get(property.getKey().getName()) != null || !(property.getValue() instanceof SinglePropertyMapper)) {
allNullAndSingle = false;
break;
}
}
if (allNullAndSingle) {
// single property, but default value need not be null, so we'll set it to null anyway
setter.set(obj, null, null);
} else {
// set the component
try {
Object subObj = ReflectHelper.getDefaultConstructor(
ReflectHelper.classForName(componentClassName)).newInstance();
setter.set(obj, subObj, null);
delegate.mapToEntityFromMap(verCfg, subObj, data, primaryKey, versionsReader, revision);
} catch (Exception e) {
throw new AuditException(e);
}
}