@Override public Method getWriteMethod() throws NoSuchMethodException { if (writeMethod == null || writeMethod.get() == null) { if (customSetMethod != null && !MappingUtils.isDeepMapping(fieldName)) { Method method = ReflectionUtils.findAMethod(clazz, customSetMethod); writeMethod = new SoftReference<Method>(method); } else { return super.getWriteMethod(); } } return writeMethod.get(); }
@Override public Method getWriteMethod() throws NoSuchMethodException { if (writeMethod == null || writeMethod.get() == null) { if (customSetMethod != null && !MappingUtils.isDeepMapping(fieldName)) { Method method = ReflectionUtils.findAMethod(clazz, customSetMethod); writeMethod = new SoftReference<Method>(method); } else { return super.getWriteMethod(); } } return writeMethod.get(); }
@Override public Method getWriteMethod() throws NoSuchMethodException { if (writeMethod == null || writeMethod.get() == null) { if (customSetMethod != null && !MappingUtils.isDeepMapping(fieldName)) { Method method = ReflectionUtils.findAMethod(clazz, customSetMethod); writeMethod = new SoftReference<Method>(method); } else { return super.getWriteMethod(); } } return writeMethod.get(); }
public FieldMap getFieldMapUsingDest(String destFieldName, boolean isMap) { if (fieldMaps == null) { return null; } FieldMap result = null; for (FieldMap fieldMap : fieldMaps) { String fieldName = fieldMap.getDestFieldName(); if (isMap && MappingUtils.isDeepMapping(fieldName)) { fieldName = fieldName.split("\\.")[0]; } String alternateFieldName = provideAlternateName(fieldName); // Check for exact match on field name. Also, check against alternate field name. The alternate field // name is used just in case the attribute was specified in the dozer xml file starting in a Capital letter. // This prevents the field from getting double mapped in the case that the class attr is named "field1" but in // the dozer xml is it specified as "Field1". This should never happen, but check just in case since the use case // doesnt actually error out. It just double maps which is a problem when the data type is a Collections. if (fieldName.equals(destFieldName) || alternateFieldName.equals(destFieldName)) { result = fieldMap; break; } } return result; }
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; }
String fieldName = fieldMap.getDestFieldName(); if (isMap && MappingUtils.isDeepMapping(fieldName)) { fieldName = fieldName.split("\\.")[0];
public static DeepHierarchyElement[] getDeepFieldHierarchy(Class<?> parentClass, String field, HintContainer deepIndexHintContainer) { if (!MappingUtils.isDeepMapping(field)) { MappingUtils.throwMappingException("Field does not contain deep field delimitor");
String fieldName = fieldMap.getDestFieldName(); if (isMap && MappingUtils.isDeepMapping(fieldName)) { fieldName = fieldName.split("\\.")[0];
private static DozerPropertyDescriptor[] getDeepFieldHierarchy(Class<?> parentClass, String field, HintContainer deepIndexHintContainer) { if (!MappingUtils.isDeepMapping(field)) { MappingUtils.throwMappingException("Field does not contain deep field delimiter");
PropertyDescriptor result = null; if (MappingUtils.isDeepMapping(fieldName)) { DeepHierarchyElement[] hierarchy = getDeepFieldHierarchy(objectClass, fieldName, deepIndexHintContainer); result = hierarchy[hierarchy.length - 1].getPropDescriptor();
PropertyDescriptor result = null; if (MappingUtils.isDeepMapping(fieldName)) { DeepHierarchyElement[] hierarchy = getDeepFieldHierarchy(objectClass, fieldName, deepIndexHintContainer); result = hierarchy[hierarchy.length - 1].getPropDescriptor();
public static PropertyDescriptor findPropertyDescriptor(Class<?> objectClass, String fieldName, HintContainer deepIndexHintContainer) { PropertyDescriptor result = null; if (MappingUtils.isDeepMapping(fieldName)) { DeepHierarchyElement[] hierarchy = getDeepFieldHierarchy(objectClass, fieldName, deepIndexHintContainer); result = hierarchy[hierarchy.length - 1].getPropDescriptor();
@Override public void setPropertyValue(Object bean, Object value, FieldMap fieldMap) { if (MappingUtils.isDeepMapping(fieldName)) { writeDeepDestinationValue(bean, value, fieldMap); } else { if (!getPropertyType().isPrimitive() || value != null) { // Check if dest value is already set and is equal to src value. If true, no need to rewrite the dest value try { // We should map null values to create a new key in the map if (value != null && getPropertyValue(bean) == value) { return; } } catch (Exception e) { // if we failed to read the value, assume we must write, and continue... } invokeWriteMethod(bean, value); } } }
@Override public void setPropertyValue(Object bean, Object value, FieldMap fieldMap) { if (MappingUtils.isDeepMapping(fieldName)) { writeDeepDestinationValue(bean, value, fieldMap); } else { if (!getPropertyType().isPrimitive() || value != null) { // Check if dest value is already set and is equal to src value. // If true, no need to rewrite the dest value try { // We should map null values to create a new key in the map if (value != null && getPropertyValue(bean) == value) { return; } } catch (Exception e) { // if we failed to read the value, assume we must write, and // continue... } invokeWriteMethod(bean, value); } } }
@Override public void setPropertyValue(Object bean, Object value, FieldMap fieldMap) { if (MappingUtils.isDeepMapping(fieldName)) { writeDeepDestinationValue(bean, value, fieldMap); } else { if (!getPropertyType().isPrimitive() || value != null) { // Check if dest value is already set and is equal to src value. // If true, no need to rewrite the dest value try { // We should map null values to create a new key in the map if (value != null && getPropertyValue(bean) == value) { 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) { 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 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; }
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); } } } }