Source:
protected <T extends RassXmlObject, R extends PersistableBusinessObject> R buildAndPopulateBusinessObjectFromPojo(T xmlObject, Supplier<R> businessObjectSupplier, RassObjectTranslationDefinition<T, R> objectDefinition, String maintenanceAction) { Class<R> businessObjectClass = objectDefinition.getBusinessObjectClass(); R businessObject = businessObjectSupplier.get(); List<String> missingRequiredFields = new ArrayList<>(); boolean isNewObject = StringUtils.equalsIgnoreCase(maintenanceAction, KRADConstants.MAINTENANCE_NEW_ACTION); boolean isObjectEdit = StringUtils.equalsIgnoreCase(maintenanceAction, KRADConstants.MAINTENANCE_EDIT_ACTION); for (RassPropertyDefinition propertyMapping : objectDefinition.getPropertyMappings()) { if (isObjectEdit && propertyMapping.isSkipForObjectEdit()) { continue; } Object xmlPropertyValue = ObjectPropertyUtils.getPropertyValue(xmlObject, propertyMapping.getXmlPropertyName()); RassValueConverter valueConverter = propertyMapping.getValueConverter(); Object convertedValue = valueConverter.convert(businessObjectClass, propertyMapping, xmlPropertyValue); if (convertedValue == null && propertyMapping.isRequired()) { missingRequiredFields.add(propertyMapping.getXmlPropertyName()); } else if (propertyMapping instanceof RassListPropertyDefinition) { RassListPropertyDefinition listPropertyMapping = (RassListPropertyDefinition) propertyMapping; List<?> newSubObjects = (List<?>) convertedValue; copyForeignKeyValuesToNewSubObjects(businessObject, listPropertyMapping, newSubObjects); mergeBusinessObjectListProperty(businessObject, (RassListPropertyDefinition) propertyMapping, (List<?>) convertedValue); } else { ObjectPropertyUtils.setPropertyValue(businessObject, propertyMapping.getBoPropertyName(), convertedValue); } } if (!missingRequiredFields.isEmpty()) { throw new RuntimeException(objectDefinition.printObjectLabelAndKeys(xmlObject) + " is missing values for the following required fields: " + missingRequiredFields.toString()); } if (isNewObject) { objectDefinition.makeBusinessObjectActiveIfApplicable(xmlObject, businessObject); } return businessObject; }

Target:
protected <T extends RassXmlObject, R extends PersistableBusinessObject> R buildAndPopulateBusinessObjectFromPojo(T xmlObject, Supplier<R> businessObjectSupplier, RassObjectTranslationDefinition<T, R> objectDefinition, String maintenanceAction) { Class<R> businessObjectClass = objectDefinition.getBusinessObjectClass(); R businessObject = businessObjectSupplier.get(); List<String> missingRequiredFields = new ArrayList<>(); for (RassPropertyDefinition propertyMapping : objectDefinition.getPropertyMappingsApplicableForAction(maintenanceAction)) { Object xmlPropertyValue = ObjectPropertyUtils.getPropertyValue(xmlObject, propertyMapping.getXmlPropertyName()); RassValueConverter valueConverter = propertyMapping.getValueConverter(); Object convertedValue = valueConverter.convert(businessObjectClass, propertyMapping, xmlPropertyValue); if (convertedValue == null && propertyMapping.isRequired()) { missingRequiredFields.add(propertyMapping.getXmlPropertyName()); } else if (propertyMapping instanceof RassListPropertyDefinition) { RassListPropertyDefinition listPropertyMapping = (RassListPropertyDefinition) propertyMapping; List<?> newSubObjects = (List<?>) convertedValue; copyForeignKeyValuesToNewSubObjects(businessObject, listPropertyMapping, newSubObjects); mergeBusinessObjectListProperty(businessObject, (RassListPropertyDefinition) propertyMapping, (List<?>) convertedValue); } else { ObjectPropertyUtils.setPropertyValue(businessObject, propertyMapping.getBoPropertyName(), convertedValue); } } if (!missingRequiredFields.isEmpty()) { throw new RuntimeException(objectDefinition.printObjectLabelAndKeys(xmlObject) + " is missing values for the following required fields: " + missingRequiredFields.toString()); } if (StringUtils.equalsIgnoreCase(maintenanceAction, KRADConstants.MAINTENANCE_NEW_ACTION)) { objectDefinition.makeBusinessObjectActiveIfApplicable(xmlObject, businessObject); } return businessObject; }