@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; }
private PrepareTargetObjectResult prepareTargetObject(Object destObj) { if (isDestFieldAccessible()) { pd = new FieldPropertyDescriptor(destObj.getClass(), getDestFieldName(), isDestFieldIndexed(), getDestFieldIndex(), getSrcDeepIndexHintContainer(), getDestDeepIndexHintContainer()); } else { pd = new JavaBeanPropertyDescriptor(destObj.getClass(), getDestFieldName(), isDestFieldIndexed(), getDestFieldIndex(), getSrcDeepIndexHintContainer(), getDestDeepIndexHintContainer()); if (targetObject == null) { if (getDestHintContainer() != null) { if (MappingUtils.isSupportedMap(c)) { if (MappingUtils.isSupportedMap(getDestHintContainer().getHint())) { c = getDestHintContainer().getHint(); c = getDestHintContainer().getHint(); return new PrepareTargetObjectResult(targetObject, new MapPropertyDescriptor(c, getDestFieldName(), isDestFieldIndexed(), getDestFieldIndex(), MappingUtils.isSupportedMap(c) ? "put" : getDestFieldMapSetMethod(), MappingUtils.isSupportedMap(c) ? "get" : getDestFieldMapGetMethod(), getDestFieldKey() != null ? getDestFieldKey() : getSrcFieldName(), getSrcDeepIndexHintContainer(), getDestDeepIndexHintContainer()));
private Class<?> determineActualPropertyType(String fieldName, boolean isIndexed, int index, Object targetObj, boolean isDestObj) { // Dig out actual Map object by calling getter on top level object DozerPropertyDescriptor pd; if ((isDestObj && isDestFieldAccessible()) || (!isDestObj && isSrcFieldAccessible())) { pd = new FieldPropertyDescriptor(targetObj.getClass(), fieldName, isIndexed, index, getSrcDeepIndexHintContainer(), getDestDeepIndexHintContainer()); } else { pd = new JavaBeanPropertyDescriptor(targetObj.getClass(), fieldName, isIndexed, index, getSrcDeepIndexHintContainer(), getDestDeepIndexHintContainer()); } return pd.getPropertyType(); }
@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); }
FieldMap fieldMap = new MapFieldMap(classMap); DozerField srcField = new DozerField(MappingUtils.isSupportedMap(srcClass) ? DozerConstants.SELF_KEYWORD : fieldName, null); srcField.setKey(fieldName);
@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); }
private Class<?> determineActualPropertyType(String fieldName, boolean isIndexed, String index, Object targetObj, boolean isDestObj) { // Dig out actual Map object by calling getter on top level object DozerPropertyDescriptor pd; if ((isDestObj && isDestFieldAccessible()) || (!isDestObj && isSrcFieldAccessible())) { pd = new FieldPropertyDescriptor(targetObj.getClass(), fieldName, isIndexed, index, isDestObj ? getDestDeepIndexHintContainer() : getSrcDeepIndexHintContainer()); } else { pd = new JavaBeanPropertyDescriptor(targetObj.getClass(), fieldName, isIndexed, index, isDestObj ? getDestDeepIndexHintContainer() : getSrcDeepIndexHintContainer()); } return pd.getPropertyType(); }
FieldMap fieldMap = new MapFieldMap(classMap); DozerField srcField = new DozerField( MappingUtils.isSupportedMap(srcClass) ? DozerConstants.SELF_KEYWORD : fieldName, null);
if (isDestFieldAccessible()) { pd = new FieldPropertyDescriptor(destObj.getClass(), getDestFieldName(), isDestFieldIndexed(), getDestFieldIndex(), getDestDeepIndexHintContainer()); } else { pd = new JavaBeanPropertyDescriptor(destObj.getClass(), getDestFieldName(), isDestFieldIndexed(), getDestFieldIndex(), getDestDeepIndexHintContainer()); if (targetObject == null) { if (getDestHintContainer() != null) { if (MappingUtils.isSupportedMap(c)) { if (MappingUtils.isSupportedMap(getDestHintContainer().getHint())) { c = getDestHintContainer().getHint(); c = getDestHintContainer().getHint(); return new PrepareTargetObjectResult(targetObject, new MapPropertyDescriptor(c, getDestFieldName(), isDestFieldIndexed(), getDestFieldIndex(), MappingUtils.isSupportedMap(c) ? "put" : getDestFieldMapSetMethod(), MappingUtils.isSupportedMap(c) ? "get" : getDestFieldMapGetMethod(), getDestFieldKey() != null ? getDestFieldKey() : getSrcFieldName(), getDestDeepIndexHintContainer()));
@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); }
private Class<?> determineActualPropertyType(String fieldName, boolean isIndexed, String index, Object targetObj, boolean isDestObj) { // Dig out actual Map object by calling getter on top level object DozerPropertyDescriptor pd; if ((isDestObj && isDestFieldAccessible()) || (!isDestObj && isSrcFieldAccessible())) { pd = new FieldPropertyDescriptor(targetObj.getClass(), fieldName, isIndexed, index, isDestObj ? getDestDeepIndexHintContainer() : getSrcDeepIndexHintContainer()); } else { pd = new JavaBeanPropertyDescriptor(targetObj.getClass(), fieldName, isIndexed, index, isDestObj ? getDestDeepIndexHintContainer() : getSrcDeepIndexHintContainer()); } return pd.getPropertyType(); }
.getSrcFieldType(classMap.getSrcClassToMap()))) && !isSupportedMap( fieldMap.getDestFieldType(classMap.getDestClassToMap()))) { FieldMap fm = new MapFieldMap(fieldMap); classMap.removeFieldMapping(fieldMap); classMap.addFieldMapping(fm);
if (isDestFieldAccessible()) { pd = new FieldPropertyDescriptor(destObj.getClass(), getDestFieldName(), isDestFieldIndexed(), getDestFieldIndex(), getDestDeepIndexHintContainer()); } else { pd = new JavaBeanPropertyDescriptor(destObj.getClass(), getDestFieldName(), isDestFieldIndexed(), getDestFieldIndex(), getDestDeepIndexHintContainer()); if (getDestHintContainer() != null) { if (MappingUtils.isSupportedMap(c)) { if (MappingUtils.isSupportedMap(getDestHintContainer().getHint())) { c = getDestHintContainer().getHint(); c = getDestHintContainer().getHint(); getDestFieldName(), isDestFieldIndexed(), getDestFieldIndex(), MappingUtils.isSupportedMap(c) ? "put" : getDestFieldMapSetMethod(), MappingUtils.isSupportedMap(c) ? "get" : getDestFieldMapGetMethod(), getDestFieldKey() != null ? getDestFieldKey() : getSrcFieldName(), getDestDeepIndexHintContainer()));
|| ( isSupportedMap(fieldMap.getDestFieldType(classMap.getDestClassToMap())) ^ isSupportedMap(fieldMap.getSrcFieldType(classMap.getSrcClassToMap())) ) ) { FieldMap fm = new MapFieldMap(fieldMap); classMap.removeFieldMapping(fieldMap); classMap.addFieldMapping(fm);
.getSrcClassToMap()))) && !isSupportedMap(fieldMap.getDestFieldType(classMap .getDestClassToMap()))) { FieldMap fm = new MapFieldMap(fieldMap); classMap.removeFieldMapping(fieldMap); classMap.addFieldMapping(fm);
.isMapTypeCustomGetterSetterField() || classMap .isSrcClassMapTypeCustomGetterSetter() || classMap.isDestClassMapTypeCustomGetterSetter()) { result = new MapFieldMap(classMap); } else if (srcField.isCustomGetterSetterField() || destField.isCustomGetterSetterField()) { result = new CustomGetSetMethodFieldMap(classMap);
result = new MapFieldMap(classMap); } else if (srcField.isCustomGetterSetterField() || destField.isCustomGetterSetterField()) { result = new CustomGetSetMethodFieldMap(classMap);
public void build() { // TODO Check Map to Map mapping FieldMap result; if (srcField.isMapTypeCustomGetterSetterField() || destField.isMapTypeCustomGetterSetterField() || classMap.isSrcClassMapTypeCustomGetterSetter() || classMap.isDestClassMapTypeCustomGetterSetter()) { result = new MapFieldMap(classMap); } else if (srcField.isCustomGetterSetterField() || destField.isCustomGetterSetterField()) { result = new CustomGetSetMethodFieldMap(classMap); } else { result = new GenericFieldMap(classMap); } result.setSrcField(srcField); result.setDestField(destField); result.setType(type); result.setRelationshipType(relationshipType); result.setRemoveOrphans(removeOrphans); result.setSrcHintContainer(srcHintContainer); result.setDestHintContainer(destHintContainer); result.setSrcDeepIndexHintContainer(srcDeepIndexHintContainer); result.setDestDeepIndexHintContainer(destDeepIndexHintContainer); if (copyByReferenceSet) { result.setCopyByReference(copyByReference); } result.setMapId(mapId); result.setCustomConverter(customConverter); result.setCustomConverterId(customConverterId); result.setCustomConverterParam(customConverterParam); classMap.addFieldMapping(result); }