public FieldMappingMetadata getFieldMappingBySource(String sourceFieldName) { FieldMap fieldMap = classMap.getFieldMapUsingSrc(sourceFieldName); if (fieldMap == null) { throw new MetadataLookupException("Field mapping " + sourceFieldName + " not found for class " + classMap.getSrcClassName()); } return new DozerFieldMappingMetadata(fieldMap); }
public boolean apply(ClassMap classMap, Configuration configuration) { Class<?> srcClass = classMap.getSrcClassToMap(); Class<?> destClass = classMap.getDestClassToMap(); PropertyDescriptor[] destProperties = ReflectionUtils.getPropertyDescriptors(destClass); for (PropertyDescriptor destPropertyDescriptor : destProperties) { String fieldName = destPropertyDescriptor.getName(); if (shouldIgnoreField(fieldName, srcClass, destClass)) { continue; } // If field has already been accounted for, then skip if (classMap.getFieldMapUsingDest(fieldName) != null || classMap .getFieldMapUsingSrc(fieldName) != null) { continue; } // If destination field does not have a write method, then skip if (destPropertyDescriptor.getWriteMethod() == null) { continue; } PropertyDescriptor srcProperty = ReflectionUtils.findPropertyDescriptor(srcClass, fieldName, null); // If the sourceProperty is null we know that there is not a // corresponding property to map to. // If source property does not have a read method, then skip if (srcProperty == null || srcProperty.getReadMethod() == null) { continue; } addGenericMapping(classMap, configuration, fieldName, fieldName); } return false; }
public boolean apply(ClassMap classMap, Configuration configuration) { Class<?> srcClass = classMap.getSrcClassToMap(); Class<?> destClass = classMap.getDestClassToMap(); Set<String> destFieldNames = getAcceptsFieldsDetector(destClass).getWritableFieldNames(destClass); Set<String> srcFieldNames = getAcceptsFieldsDetector(srcClass).getReadableFieldNames(srcClass); Set<String> commonFieldNames = CollectionUtils.intersection(srcFieldNames, destFieldNames); for (String fieldName : commonFieldNames) { if (GeneratorUtils.shouldIgnoreField(fieldName, srcClass, destClass)) { continue; } // If field has already been accounted for, then skip if (classMap.getFieldMapUsingDest(fieldName) != null || classMap.getFieldMapUsingSrc(fieldName) != null) { continue; } GeneratorUtils.addGenericMapping(classMap, configuration, fieldName, fieldName); } return false; }
if (destinationIsMap && classMap.getFieldMapUsingSrc(fieldName) != null) { continue;
if (destinationIsMap && classMap.getFieldMapUsingSrc(fieldName) != null) { continue;