public ClassMap copyOf() { ClassMap copy = new ClassMap(this.globalConfiguration); copy.setSrcClass(srcClass); copy.setDestClass(destClass); copy.setFieldMaps(new ArrayList<FieldMap>(fieldMaps)); copy.setAllowedExceptions(new ArrayList<Class<RuntimeException>>(allowedExceptions)); copy.setType(type); copy.setDateFormat(dateFormat); copy.setBeanFactory(beanFactory); copy.setMapNull(mapNull); copy.setMapEmptyString(mapEmptyString); copy.setWildcard(wildcard); copy.setStopOnErrors(stopOnErrors); copy.setTrimStrings(trimStrings); copy.setCustomConverters(customConverters); copy.setMapId(mapId); copy.setRelationshipType(relationshipType); return copy; } }
public boolean apply(ClassMap classMap, Configuration configuration) { Class<?> srcClass = classMap.getSrcClassToMap(); Class<?> destClass = classMap.getDestClassToMap(); PropertyDescriptor[] properties; boolean destinationIsMap = false; if (MappingUtils.isSupportedMap(srcClass) || classMap.getSrcClassMapGetMethod() != null) { properties = ReflectionUtils.getPropertyDescriptors(destClass); } else { if (destinationIsMap && classMap.getFieldMapUsingSrc(fieldName) != null) { continue; if (!destinationIsMap && classMap.getFieldMapUsingDest(fieldName, true) != null) { continue; if (StringUtils.isNotEmpty(classMap.getSrcClassMapGetMethod()) || StringUtils.isNotEmpty(classMap.getSrcClassMapSetMethod())) { srcField.setMapGetMethod(classMap.getSrcClassMapGetMethod()); srcField.setMapSetMethod(classMap.getSrcClassMapSetMethod()); srcField.setName(DozerConstants.SELF_KEYWORD); if (StringUtils.isNotEmpty(classMap.getDestClassMapGetMethod()) || StringUtils.isNotEmpty(classMap.getDestClassMapSetMethod())) { destField.setMapGetMethod(classMap.getDestClassMapGetMethod()); destField.setMapSetMethod(classMap.getDestClassMapSetMethod()); destField.setName(DozerConstants.SELF_KEYWORD); classMap.addFieldMapping(fieldMap);
public static void reverseFields(ClassMap source, ClassMap destination) { // reverse the fields destination.setSrcClass(new DozerClass(source.getDestClassName(), source.getDestClassToMap(), source.getDestClassBeanFactory(), source.getDestClassBeanFactoryId(), source.getDestClassMapGetMethod(), source.getDestClassMapSetMethod(), source.getDestClass().getCreateMethod(), source.isDestMapNull(), source.isDestMapEmptyString(), source.getDestClass().isAccesible())); destination.setDestClass(new DozerClass(source.getSrcClassName(), source.getSrcClassToMap(), source.getSrcClassBeanFactory(), source.getSrcClassBeanFactoryId(), source.getSrcClassMapGetMethod(), source.getSrcClassMapSetMethod(), source.getSrcClass().getCreateMethod(), source.isSrcMapNull(), source.isSrcMapEmptyString(), source.getSrcClass().isAccesible())); destination.setType(source.getType()); destination.setWildcard(source.isWildcard()); destination.setTrimStrings(source.isTrimStrings()); destination.setDateFormat(source.getDateFormat()); destination.setRelationshipType(source.getRelationshipType()); destination.setStopOnErrors(source.isStopOnErrors()); destination.setAllowedExceptions(source.getAllowedExceptions()); destination.setSrcClassCreateMethod(source.getDestClassCreateMethod()); destination.setDestClassCreateMethod(source.getSrcClassCreateMethod()); if (StringUtils.isNotEmpty(source.getMapId())) { destination.setMapId(source.getMapId()); } }
Class<?> srcClass, Class<?> destClass) { ClassMap classMap = new ClassMap(globalConfiguration); classMap.setSrcClass(new DozerClass(srcClass.getName(), srcClass, globalConfiguration.getBeanFactory(), DozerConstants.DEFAULT_MAP_EMPTY_STRING_POLICY, false)); classMap.setDestClass(new DozerClass(destClass.getName(), destClass, globalConfiguration.getBeanFactory(),
Set<String> mapIds = new HashSet<String>(); for (ClassMap classMap : classMaps) { classMap.setGlobalConfiguration(globalConfiguration); ReflectionUtils.findPropertyDescriptor(classMap.getSrcClassToMap(), "", null); ReflectionUtils.findPropertyDescriptor(classMap.getDestClassToMap(), "", null); if (!MappingUtils.isBlankOrNull(classMap.getMapId())) { if (mapIds.contains(classMap.getMapId())) { throw new IllegalArgumentException("Duplicate Map Id's Found. Map Id: " + classMap.getMapId()); mapIds.add(classMap.getMapId()); result.add(classMap.getSrcClassToMap(), classMap.getDestClassToMap(), classMap.getMapId(), classMap); classMapPrime = new ClassMap(globalConfiguration); if (classMap.getFieldMaps() != null) { Object[] fms = classMap.getFieldMaps().toArray(); if ((isSupportedMap(classMap.getDestClassToMap()) && !isSupportedMap(classMap .getSrcClassToMap())) || (isSupportedMap(classMap.getSrcClassToMap()) && !isSupportedMap(classMap .getDestClassToMap())) || (isSupportedMap(fieldMap.getDestFieldType(classMap .getDestClassToMap())) && !isSupportedMap(fieldMap.getSrcFieldType(classMap .getSrcClassToMap()))) || (isSupportedMap(fieldMap.getSrcFieldType(classMap .getSrcClassToMap()))) && !isSupportedMap(fieldMap.getDestFieldType(classMap .getDestClassToMap()))) { FieldMap fm = new MapFieldMap(fieldMap); classMap.removeFieldMapping(fieldMap);
Class<?> converterClass = MappingUtils.findCustomConverter(converterByDestTypeCache, classMap.getCustomConverters(), srcObj .getClass(), destType); new BeanCreationDirective(srcObj, classMap.getSrcClassToMap(), classMap.getDestClassToMap(), destType, classMap.getDestClassBeanFactory(), classMap.getDestClassBeanFactoryId(), classMap.getDestClassCreateMethod());
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); }
} catch (Exception e) { if (fieldMap.getClassMap().getDestClassBeanFactory() != null) { o = DestBeanCreator.create(new BeanCreationDirective(null, fieldMap.getClassMap().getSrcClassToMap(), clazz, clazz, fieldMap.getClassMap() .getDestClassBeanFactory(), fieldMap.getClassMap().getDestClassBeanFactoryId(), null)); } else { MappingUtils.throwMappingException(e);
LogMsgFactory.getLogOutput(srcObj), LogMsgFactory.getLogOutput(destObj), classMap.getSrcClassToMap(), classMap.getDestClassToMap())); classMap.getCustomConverters(), srcClass, destClass); if (converter != null) { mapUsingCustomConverterInstance(converter, srcClass, srcObj, destClass, destObj, null, context, true);
public void build() { ClassMap classMap = fieldMap.getClassMap(); classMap.addFieldMapping(fieldMap); } }
if (classMap.getCustomConverters() != null) { classMap.getCustomConverters().setConverters(new ArrayList<CustomConverterDescription>(customConverterDescriptions)); } else { classMap.setCustomConverters(new CustomConverterContainer()); classMap.getCustomConverters().setConverters(new ArrayList<CustomConverterDescription>(customConverterDescriptions));
customConverterObjects, fieldMapping.getClassMap().getCustomConverters(), value.getClass(), fieldMapping.getDestHintContainer().getHint()); log.debug(LogMsgFactory.createFieldMappingSuccessMsg(srcObj.getClass(), destObj.getClass(), fieldMapping .getSrcFieldName(), fieldMapping.getDestFieldName(), srcFieldValue, null, fieldMapping.getClassMap() .getMapId()));
Class<?> converterClass = MappingUtils.findCustomConverter(converterByDestTypeCache, classMap.getCustomConverters(), srcClass, destClass); if (converterClass != null) { for (FieldMap fieldMapping : classMap.getFieldMaps()) {
public static DozerPropertyDescriptor getPropertyDescriptor(Class<?> clazz, ClassMap classMap, DozerField src, DozerField dest) { if (MappingUtils.isBlankOrNull(src.getName())) { return new EmptyFieldPropertyDescriptor(); } LOG.info("clazz = " + clazz.getName()); LOG.info("src.getTheGetMethod() = " + src.getTheGetMethod()); LOG.info("src.getTheSetMethod() = " + src.getTheSetMethod()); LOG.info("src.getMapGetMethod() = " + src.getMapGetMethod()); LOG.info("src.getMapSetMethod() = " + src.getMapSetMethod()); LOG.info("src.isAccessible() = " + src.isAccessible()); LOG.info("src.isIndexed() = " + src.isIndexed()); LOG.info("src.getIndex() = " + src.getIndex()); LOG.info("src.getName() = " + src.getName()); LOG.info("src.getKey() = " + src.getKey()); LOG.info("src.isSelfReferenced() = " + src.isSelfReferenced()); LOG.info("src.getName() = " + src.getName()); LOG.info("src.getDeepIndexHintContainer() = " + src.getDeepIndexHintContainer()); LOG.info("classMap.getDestClassBeanFactory() = " + classMap.getDestClassBeanFactory()); return getPropertyDescriptor(clazz, src.getTheGetMethod(), src.getTheSetMethod(), src.getMapGetMethod(), src.getMapSetMethod(), src.isAccessible(), src.isIndexed(), src.getIndex(), src.getName(), src .getKey(), src.isSelfReferenced(), src.getName(), src.getDeepIndexHintContainer(), classMap.getDestClassBeanFactory()); }
public String getDateFormat() { return classMap.getDateFormat(); }
public String getSrcClassBeanFactory() { return !MappingUtils.isBlankOrNull(srcClass.getBeanFactory()) ? srcClass.getBeanFactory() : getBeanFactory(); }
public MappingBuilder mapping() { Configuration configuration = data.getConfiguration(); ClassMap classMap = new ClassMap(configuration); data.getClassMaps().add(classMap); MappingBuilder mappingDefinitionBuilder = new MappingBuilder(classMap); mappingBuilders.add(mappingDefinitionBuilder); return mappingDefinitionBuilder; }
public boolean isDestFieldAccessible() { return determineAccess(destField, classMap.getDestClass()); }
} else { if (!fieldMapping.getClassMap().getAllowedExceptions().isEmpty() && e.getCause() instanceof InvocationTargetException) { Throwable thrownType = ((InvocationTargetException) e.getCause()).getTargetException(); Class<? extends Throwable> exceptionClass = thrownType.getClass(); if (fieldMapping.getClassMap().getAllowedExceptions().contains(exceptionClass)) { throw (RuntimeException) thrownType;
private Object mapOrRecurseObject(Object srcObj, Object srcFieldValue, Class<?> destFieldType, FieldMap fieldMap, Object destObj) { Class<?> srcFieldClass = srcFieldValue != null ? srcFieldValue.getClass() : fieldMap.getSrcFieldType(srcObj.getClass()); Class<?> converterClass = MappingUtils.determineCustomConverter(fieldMap, converterByDestTypeCache, fieldMap.getClassMap() .getCustomConverters(), srcFieldClass, destFieldType);