Source:
<code>private Element createPropertiesElement(List<PropertyDescriptor<?>> propertyDescriptors, Map<PropertyDescriptor<?>, Object> propertiesByPropertyDescriptor) { Element propertiesElement = null; if (propertyDescriptors != null) { for (PropertyDescriptor<?> propertyDescriptor : propertyDescriptors) { <START> if (propertyDescriptor instanceof PropertyDescriptorWrapper) { <END> if (propertiesElement == null) { propertiesElement = createPropertiesElement(); } Element propertyElement = createPropertyDefinitionElementBR( ((PropertyDescriptorWrapper<?>) propertyDescriptor).getPropertyDescriptor()); propertiesElement.appendChild(propertyElement); } else { if (propertiesByPropertyDescriptor != null) { Object defaultValue = propertyDescriptor.defaultValue(); Object value = propertiesByPropertyDescriptor.get(propertyDescriptor); if (value != defaultValue && (value == null || !value.equals(defaultValue))) { if (propertiesElement == null) { propertiesElement = createPropertiesElement(); } Element propertyElement = createPropertyValueElement(propertyDescriptor, value); propertiesElement.appendChild(propertyElement); } } } } } if (propertiesByPropertyDescriptor != null) { for (Map.Entry<PropertyDescriptor<?>, Object> entry : propertiesByPropertyDescriptor.entrySet()) { PropertyDescriptor<?> propertyDescriptor = entry.getKey(); if (!propertyDescriptors.contains(propertyDescriptor)) { Object defaultValue = propertyDescriptor.defaultValue(); Object value = entry.getValue(); if (value != defaultValue && (value == null || !value.equals(defaultValue))) { if (propertiesElement == null) { propertiesElement = createPropertiesElement(); } Element propertyElement = createPropertyValueElement(propertyDescriptor, value); propertiesElement.appendChild(propertyElement); } } } } return propertiesElement; }</code><technical_language>I consider boolean, I felt lacked clarity get point across. Welcome implement of course. I considering a change immutability. clear factories delineate scenarios, currently publicly available, Rules them. current means default INTERNAL, provide another new means factory for creating EXTERNAL, wrappers created? This prevent accidental misuse, limit flexibility</technical_language>

Target:
private Element createPropertiesElement(List<PropertyDescriptor<?>> propertyDescriptors, Map<PropertyDescriptor<?>, Object> propertiesByPropertyDescriptor) { Element propertiesElement = null; if (propertyDescriptors != null) { for (PropertyDescriptor<?> propertyDescriptor : propertyDescriptors) { if (propertyDescriptor.isDefinedExternally()) { if (propertiesElement == null) { propertiesElement = createPropertiesElement(); } Element propertyElement = createPropertyDefinitionElementBR(propertyDescriptor); propertiesElement.appendChild(propertyElement); } else { if (propertiesByPropertyDescriptor != null) { Object defaultValue = propertyDescriptor.defaultValue(); Object value = propertiesByPropertyDescriptor.get(propertyDescriptor); if (value != defaultValue && (value == null || !value.equals(defaultValue))) { if (propertiesElement == null) { propertiesElement = createPropertiesElement(); } Element propertyElement = createPropertyValueElement(propertyDescriptor, value); propertiesElement.appendChild(propertyElement); } } } } } if (propertiesByPropertyDescriptor != null) { for (Map.Entry<PropertyDescriptor<?>, Object> entry : propertiesByPropertyDescriptor.entrySet()) { PropertyDescriptor<?> propertyDescriptor = entry.getKey(); if (!propertyDescriptors.contains(propertyDescriptor)) { Object defaultValue = propertyDescriptor.defaultValue(); Object value = entry.getValue(); if (value != defaultValue && (value == null || !value.equals(defaultValue))) { if (propertiesElement == null) { propertiesElement = createPropertiesElement(); } Element propertyElement = createPropertyValueElement(propertyDescriptor, value); propertiesElement.appendChild(propertyElement); } } } } return propertiesElement; }