public boolean accepts(ClassMap classMap) { Class<?> srcClass = classMap.getSrcClassToMap(); Class<?> destClass = classMap.getDestClassToMap(); return MappingUtils.isSupportedMap(srcClass) || classMap.getSrcClassMapGetMethod() != null || MappingUtils.isSupportedMap(destClass) || classMap.getDestClassMapGetMethod() != null; }
public boolean accepts(ClassMap classMap) { Class<?> srcClass = classMap.getSrcClassToMap(); Class<?> destClass = classMap.getDestClassToMap(); return MappingUtils.isSupportedMap(srcClass) || classMap.getSrcClassMapGetMethod() != null || MappingUtils .isSupportedMap(destClass) || classMap.getDestClassMapGetMethod() != null; }
private static Object getExistingValue(FieldMap fieldMap, Object destObj, Class<?> destFieldType) { // verify that the dest obj is not null if (destObj == null) { return null; } // call the getXX method to see if the field is already instantiated Object result = fieldMap.getDestValue(destObj); // When we are recursing through a list we need to make sure that we are not // in the list // by checking the destFieldType if (result != null) { if (CollectionUtils.isList(result.getClass()) || CollectionUtils.isArray(result.getClass()) || CollectionUtils.isSet(result.getClass()) || MappingUtils.isSupportedMap(result.getClass())) { if (!CollectionUtils.isList(destFieldType) && !CollectionUtils.isArray(destFieldType) && !CollectionUtils.isSet(destFieldType) && !MappingUtils.isSupportedMap(destFieldType)) { // this means the getXX field is a List but we are actually trying to // map one of its elements result = null; } } } return result; }
@Override public void writeDestValue(Object destObj, Object destFieldValue) { DozerPropertyDescriptor propDescriptor; Object targetObject = destObj; if (getDestFieldName().equals(DozerConstants.SELF_KEYWORD) || (destFieldValue != null && MappingUtils.isSupportedMap(destFieldValue.getClass()))) { // Destination value is already a Map, so just use normal propDescriptor = super.getDestPropertyDescriptor(destObj.getClass()); } else { if (getDestFieldMapGetMethod() != null || MappingUtils.isSupportedMap(determineActualPropertyType(getDestFieldName(), isDestFieldIndexed(), getDestFieldIndex(), destObj, true))) { // Need to dig out actual destination Map object and use map property descriptor to set the value on that target object.... PrepareTargetObjectResult result = prepareTargetObject(destObj); targetObject = result.targetObject; propDescriptor = result.propDescriptor; } else { propDescriptor = super.getDestPropertyDescriptor(destObj.getClass()); } } propDescriptor.setPropertyValue(targetObject, destFieldValue, this); }
@Override public void writeDestValue(Object destObj, Object destFieldValue) { DozerPropertyDescriptor propDescriptor; Object targetObject = destObj; if (getDestFieldName().equals(DozerConstants.SELF_KEYWORD) || (destFieldValue != null && MappingUtils .isSupportedMap(destFieldValue.getClass()))) { // Destination value is already a Map, so just use normal propDescriptor = super.getDestPropertyDescriptor(destObj.getClass()); } else { if (getDestFieldMapGetMethod() != null || MappingUtils.isSupportedMap(determineActualPropertyType( getDestFieldName(), isDestFieldIndexed(), getDestFieldIndex(), destObj, true))) { // Need to dig out actual destination Map object and use map // property descriptor to set the value on that target // object.... PrepareTargetObjectResult result = prepareTargetObject(destObj); targetObject = result.targetObject; propDescriptor = result.propDescriptor; } else { propDescriptor = super.getDestPropertyDescriptor(destObj.getClass()); } } propDescriptor.setPropertyValue(targetObject, destFieldValue, this); }
@Override public void writeDestValue(Object destObj, Object destFieldValue) { DozerPropertyDescriptor propDescriptor; Object targetObject = destObj; if (getDestFieldName().equals(DozerConstants.SELF_KEYWORD) || (destFieldValue != null && MappingUtils .isSupportedMap(destFieldValue.getClass()))) { // Destination value is already a Map, so just use normal propDescriptor = super.getDestPropertyDescriptor(destObj.getClass()); } else { if (getDestFieldMapGetMethod() != null || MappingUtils.isSupportedMap(determineActualPropertyType( getDestFieldName(), isDestFieldIndexed(), getDestFieldIndex(), destObj, true))) { // Need to dig out actual destination Map object and use map // property descriptor to set the value on that target // object.... PrepareTargetObjectResult result = prepareTargetObject(destObj); targetObject = result.targetObject; propDescriptor = result.propDescriptor; } else { propDescriptor = super.getDestPropertyDescriptor(destObj.getClass()); } } propDescriptor.setPropertyValue(targetObject, destFieldValue, this); }
boolean isMapProperty = MappingUtils.isSupportedMap(clazz); if (name.equals(DozerConstants.SELF_KEYWORD) && (mapSetMethod != null || mapGetMethod != null || isMapProperty)) {
boolean isMapProperty = MappingUtils.isSupportedMap(clazz);
|| CollectionUtils.isArray(result.getClass()) || CollectionUtils.isSet(result.getClass()) || MappingUtils.isSupportedMap(result.getClass())) { && !MappingUtils.isSupportedMap(destFieldType)) {
@Override public Object getSrcFieldValue(Object srcObj) { DozerPropertyDescriptor propDescriptor; Object targetObject = srcObj; if (getSrcFieldName().equals(DozerConstants.SELF_KEYWORD)) { propDescriptor = super.getSrcPropertyDescriptor(srcObj.getClass()); } else { Class<?> actualType = determineActualPropertyType(getSrcFieldName(), isSrcFieldIndexed(), getSrcFieldIndex(), srcObj, false); if ((getSrcFieldMapGetMethod() != null) || (this.getMapId() == null && MappingUtils.isSupportedMap(actualType) && getSrcHintContainer() == null)) { // Need to dig out actual map object by using getter on the field. Use actual map object to get the field value targetObject = super.getSrcFieldValue(srcObj); String setMethod = MappingUtils.isSupportedMap(actualType) ? "put" : getSrcFieldMapSetMethod(); String getMethod = MappingUtils.isSupportedMap(actualType) ? "get" : getSrcFieldMapGetMethod(); String key = getSrcFieldKey() != null ? getSrcFieldKey() : getDestFieldName(); propDescriptor = new MapPropertyDescriptor(actualType, getSrcFieldName(), isSrcFieldIndexed(), getDestFieldIndex(), setMethod, getMethod, key, getSrcDeepIndexHintContainer(), getDestDeepIndexHintContainer()); } else { propDescriptor = super.getSrcPropertyDescriptor(srcObj.getClass()); } } Object result = null; if (targetObject != null) { result = propDescriptor.getPropertyValue(targetObject); } return result; }
if (CollectionUtils.isList(result.getClass()) || CollectionUtils .isArray(result.getClass()) || CollectionUtils .isSet(result.getClass()) || MappingUtils.isSupportedMap(result.getClass())) { .isSet(destFieldType) && !MappingUtils.isSupportedMap(destFieldType)) {
boolean destinationIsMap = false; if (MappingUtils.isSupportedMap(srcClass) || classMap.getSrcClassMapGetMethod() != null) { properties = ReflectionUtils.getPropertyDescriptors(destClass); } else { DozerField srcField = new DozerField(MappingUtils.isSupportedMap(srcClass) ? DozerConstants.SELF_KEYWORD : fieldName, null); srcField.setKey(fieldName); DozerField destField = new DozerField(MappingUtils.isSupportedMap(destClass) ? DozerConstants.SELF_KEYWORD : fieldName, null); srcField.setKey(fieldName);
Class<?> srcFieldType = srcCollectionValue.getClass(); if (fieldMap instanceof MapFieldMap && (MappingUtils.isSupportedMap(fieldMap.getDestFieldType(destObj.getClass())) || (DozerConstants.SELF_KEYWORD.equals(fieldMap.getDestFieldName())) && MappingUtils.isSupportedMap(fieldMap.getClassMap().getDestClassToMap()))) { destCollectionType = srcFieldType; else if (CollectionUtils.isCollection(srcFieldType) && MappingUtils.isSupportedMap(destCollectionType)) { result = mapListToList(srcObj, (List<?>) srcCollectionValue, fieldMap, destObj, context);
if (MappingUtils.isSupportedMap(c)) { if (MappingUtils.isSupportedMap(getDestHintContainer().getHint())) { c = getDestHintContainer().getHint(); isDestFieldIndexed(), getDestFieldIndex(), MappingUtils.isSupportedMap(c) ? "put" : getDestFieldMapSetMethod(), MappingUtils.isSupportedMap(c) ? "get" : getDestFieldMapGetMethod(), getDestFieldKey() != null ? getDestFieldKey() : getSrcFieldName(), getDestDeepIndexHintContainer()));
Class<?> srcFieldType = srcCollectionValue.getClass(); if (fieldMap instanceof MapFieldMap && (MappingUtils.isSupportedMap(fieldMap.getDestFieldType( destObj.getClass())) || (DozerConstants.SELF_KEYWORD.equals(fieldMap.getDestFieldName())) && MappingUtils .isSupportedMap(fieldMap.getClassMap().getDestClassToMap()))) { destCollectionType = srcFieldType; else if (CollectionUtils.isCollection(srcFieldType) && MappingUtils.isSupportedMap(destCollectionType)) { result = mapListToList(srcObj, (List<?>) srcCollectionValue, fieldMap, destObj, context);
boolean destinationIsMap = false; if (MappingUtils.isSupportedMap(srcClass) || classMap.getSrcClassMapGetMethod() != null) { properties = ReflectionUtils.getPropertyDescriptors(destClass); } else { MappingUtils.isSupportedMap(srcClass) ? DozerConstants.SELF_KEYWORD : fieldName, null); srcField.setKey(fieldName); MappingUtils.isSupportedMap(destClass) ? DozerConstants.SELF_KEYWORD : fieldName, null); srcField.setKey(fieldName);
if (MappingUtils.isSupportedMap(c)) { if (MappingUtils.isSupportedMap(getDestHintContainer().getHint())) { c = getDestHintContainer().getHint(); getDestFieldIndex(), MappingUtils.isSupportedMap(c) ? "put" : getDestFieldMapSetMethod(), MappingUtils.isSupportedMap(c) ? "get" : getDestFieldMapGetMethod(), getDestFieldKey() != null ? getDestFieldKey() : getSrcFieldName(), getSrcDeepIndexHintContainer(), getDestDeepIndexHintContainer()));
boolean isSrcFieldClassSupportedMap = MappingUtils.isSupportedMap(srcFieldClass); boolean isDestFieldTypeSupportedMap = MappingUtils.isSupportedMap(destFieldType); if (isSrcFieldClassSupportedMap && isDestFieldTypeSupportedMap) { return mapMap(srcObj, (Map<?, ?>) srcFieldValue, fieldMap, destObj);
if (MappingUtils.isSupportedMap(c)) { if (MappingUtils.isSupportedMap(getDestHintContainer().getHint())) { c = getDestHintContainer().getHint(); isDestFieldIndexed(), getDestFieldIndex(), MappingUtils.isSupportedMap(c) ? "put" : getDestFieldMapSetMethod(), MappingUtils.isSupportedMap(c) ? "get" : getDestFieldMapGetMethod(), getDestFieldKey() != null ? getDestFieldKey() : getSrcFieldName(), getDestDeepIndexHintContainer()));
else if (CollectionUtils.isCollection(srcFieldType) && MappingUtils.isSupportedMap(destCollectionType)) { result = mapListToList(srcObj, (List<?>) srcCollectionValue, fieldMap, destObj);