public void setPropertyValue(Object bean, Object value, FieldMap fieldMap) { if (MappingUtils.isDeepMapping(fieldName)) { writeDeepDestinationValue(bean, value, fieldMap); } else { if (!getPropertyType().isPrimitive() || value != null) { //First check if value is indexed. If it's null, then the new array will be created if (isIndexed) { writeIndexedValue(bean, value); } else { // Check if dest value is already set and is equal to src value. If true, no need to rewrite the dest value try { if (getPropertyValue(bean) == value && !isIndexed) { return; } } catch (Exception e) { // if we failed to read the value, assume we must write, and continue... } invokeWriteMethod(bean, value); } } } }
public void setPropertyValue(Object bean, Object value, FieldMap fieldMap) { if (MappingUtils.isDeepMapping(fieldName)) { writeDeepDestinationValue(bean, value, fieldMap); } else { if (!getPropertyType().isPrimitive() || value != null) { // First check if value is indexed. If it's null, then the new // array will be created if (isIndexed) { // write value using index information // writeIndexedValue(bean, value); } else { // Check if dest value is already set and is equal to src // value. If true, no need to rewrite the dest value try { if (getPropertyValue(bean) == value && !isIndexed) { return; } } catch (Exception e) { // if we failed to read the value, assume we must write, // and continue... } invokeWriteMethod(bean, value); } } } }
public void setPropertyValue(Object bean, Object value, FieldMap fieldMap) { if (MappingUtils.isDeepMapping(fieldName)) { writeDeepDestinationValue(bean, value, fieldMap); } else { if (!getPropertyType().isPrimitive() || value != null) { // First check if value is indexed. If it's null, then the new // array will be created if (isIndexed) { // write value using index information // writeIndexedValue(bean, value); } else { // Check if dest value is already set and is equal to src // value. If true, no need to rewrite the dest value try { if (getPropertyValue(bean) == value && !isIndexed) { return; } } catch (Exception e) { // if we failed to read the value, assume we must write, // and continue... } invokeWriteMethod(bean, value); } } } }
private void writeIndexedValue(Object destObj, Object destFieldValue) { if (!MappingUtils.isSimpleCollectionIndex(index)) { MappingUtils.throwMappingException("Destinaiton field path should not contain filter expressions"); } if (MappingUtils.isSimpleCollectionIndex(index)) { int collectionIndex = MappingUtils.getCollectionIndex(index); Object existingValue = invokeReadMethod(destObj); if (collectionIndex == -1) { if (existingValue != null) { collectionIndex = CollectionUtils.getLengthOfCollection(existingValue); } else { collectionIndex = 0; } } writeIndexedValue(destObj, collectionIndex, existingValue, destFieldValue); } }
private void writeIndexedValue(Object destObj, Object destFieldValue) { if (!MappingUtils.isSimpleCollectionIndex(index)) { MappingUtils.throwMappingException("Destinaiton field path should not contain filter expressions"); } if (MappingUtils.isSimpleCollectionIndex(index)) { int collectionIndex = MappingUtils.getCollectionIndex(index); Object existingValue = invokeReadMethod(destObj); if (collectionIndex == -1) { if (existingValue != null) { collectionIndex = CollectionUtils.getLengthOfCollection(existingValue); } else { collectionIndex = 0; } } writeIndexedValue(destObj, collectionIndex, existingValue, destFieldValue); } }
writeIndexedValue(parentObj, destFieldValue);
writeIndexedValue(parentObj, destFieldValue);
writeIndexedValue(parentObj, destFieldValue);