private void writeIndexedValue(Object destObj, Object destFieldValue) { Object existingValue = invokeReadMethod(destObj); Object indexedValue = MappingUtils.prepareIndexedCollection(getPropertyType(), existingValue, destFieldValue, index); invokeWriteMethod(destObj, indexedValue); }
public Object getPropertyValue(Object bean) { Object result; if (MappingUtils.isDeepMapping(fieldName)) { result = getDeepSrcFieldValue(bean); } else { result = invokeReadMethod(bean); if (isIndexed) { result = MappingUtils.getIndexedValue(result, index); } } return result; }
public Object getPropertyValue(Object bean) { Object result; if (MappingUtils.isDeepMapping(fieldName)) { result = getDeepSrcFieldValue(bean); } else { result = invokeReadMethod(bean); if (isIndexed) { if (MappingUtils.isSimpleCollectionIndex(index)) { int collectionIndex = MappingUtils.getCollectionIndex(index); result = MappingUtils.getCollectionIndexedValue(result, collectionIndex); } else { String expression = String.format("%s[%s]", fieldName, index); result = MappingUtils.getXPathIndexedValue(bean, expression); } } } return result; }
public Object getPropertyValue(Object bean) { Object result; if (MappingUtils.isDeepMapping(fieldName)) { result = getDeepSrcFieldValue(bean); } else { result = invokeReadMethod(bean); if (isIndexed) { if (MappingUtils.isSimpleCollectionIndex(index)) { int collectionIndex = MappingUtils.getCollectionIndex(index); result = MappingUtils.getCollectionIndexedValue(result, collectionIndex); } else { String expression = String.format("%s[%s]", fieldName, index); result = MappingUtils.getXPathIndexedValue(bean, expression); } } } return result; }
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); } }