collectionIndex = CollectionUtils.getLengthOfCollection(collection);
collectionIndex = CollectionUtils.getLengthOfCollection(collection);
private void mapFromIterateMethodFieldMap(Object srcObj, Object destObj, Object srcFieldValue, FieldMap fieldMapping) { // Iterate over the destFieldValue - iterating is fine unless we are mapping // in the other direction. // Verify that it is truly a collection if it is an iterator object turn it // into a List if (srcFieldValue instanceof Iterator) { srcFieldValue = IteratorUtils.toList((Iterator<?>) srcFieldValue); } if (srcFieldValue != null) { for (int i = 0; i < CollectionUtils.getLengthOfCollection(srcFieldValue); i++) { final Object value = CollectionUtils.getValueFromCollection(srcFieldValue, i); // map this value if (fieldMapping.getDestHintContainer() == null) { MappingUtils.throwMappingException("<field type=\"iterate\"> must have a source or destination type hint"); } Class<?> destinationHint = fieldMapping.getDestHintType(value.getClass()); Object result = mapOrRecurseObject(srcObj, value, destinationHint, fieldMapping, destObj); if (value != null) { writeDestinationValue(destObj, result, fieldMapping, srcObj); } } } if (log.isDebugEnabled()) { log.debug(logMsgFactory.createFieldMappingSuccessMsg(srcObj.getClass(), destObj.getClass(), fieldMapping.getSrcFieldName(), fieldMapping.getDestFieldName(), srcFieldValue, null, fieldMapping.getClassMap().getMapId())); } }
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); } }
int currentSize = CollectionUtils.getLengthOfCollection(value); if (currentSize < hierarchyElement.getIndex() + 1) { collectionEntryType = pd.getPropertyType().getComponentType();
for (int i = 0; i < CollectionUtils.getLengthOfCollection(srcFieldValue); i++) { Object value = CollectionUtils.getValueFromCollection(srcFieldValue, i);
int currentSize = CollectionUtils.getLengthOfCollection(value); String index = hierarchyElement.getIndex();
int currentSize = CollectionUtils.getLengthOfCollection(value); String index = hierarchyElement.getIndex();
for (int i = 0; i < CollectionUtils.getLengthOfCollection(srcFieldValue); i++) { Object value = CollectionUtils.getValueFromCollection(srcFieldValue, i);