@Override public Set<Type> getImportTypes() { Set<Type> types = super.getImportTypes(); if (elementAssignment != null) { types.addAll(elementAssignment.getImportTypes()); } if ((factoryMethod == null) && (!isExistingInstanceMapping())) { if (getReturnType().getImplementationType() != null) { types.addAll(getReturnType().getImplementationType().getImportTypes()); } } return types; }
public IterableMappingMethod build() { Type sourceParameterType = first(method.getSourceParameters()).getType(); Type resultType = method.getResultType(); Type sourceElementType = sourceParameterType.isArrayType() ? sourceParameterType.getComponentType() : first(sourceParameterType.getTypeParameters()).getTypeBound(); Type targetElementType = resultType.isArrayType() ? resultType.getComponentType() : first(resultType.getTypeParameters()).getTypeBound(); String loopVariableName = Strings.getSaveVariableName(sourceElementType.getName(), method.getParameterNames()); Assignment assignment = ctx.getMappingResolver() .getTargetAssignment( method, "collection element", sourceElementType, targetElementType, null, // there is no targetPropertyName formattingParameters, selectionParameters, loopVariableName, false); if (assignment == null) { if (method instanceof ForgedMethod) { // leave messaging to calling property mapping return null; } else { ctx.getMessager() .printMessage(method.getExecutable(), Message.ITERABLEMAPPING_MAPPING_NOT_FOUND); } } else { if (method instanceof ForgedMethod) { ForgedMethod forgedMethod = (ForgedMethod) method; forgedMethod.addThrownTypes(assignment.getThrownTypes()); } } // target accessor is setter, so decorate assignment as setter if (resultType.isArrayType()) { assignment = new LocalVarWrapper(assignment, method.getThrownTypes()); } else { assignment = new SetterWrapper(assignment, method.getThrownTypes()); } // mapNullToDefault boolean mapNullToDefault = false; if (method.getMapperConfiguration() != null) { mapNullToDefault = method.getMapperConfiguration().isMapToDefault(nullValueMappingStrategy); } MethodReference factoryMethod = null; if (!method.isUpdateMethod()) { factoryMethod = ctx.getMappingResolver().getFactoryMethod(method, method.getResultType(), null); } List<LifecycleCallbackMethodReference> beforeMappingMethods = LifecycleCallbackFactory.beforeMappingMethods(method, selectionParameters, ctx); List<LifecycleCallbackMethodReference> afterMappingMethods = LifecycleCallbackFactory.afterMappingMethods(method, selectionParameters, ctx); return new IterableMappingMethod( method, assignment, factoryMethod, mapNullToDefault, loopVariableName, beforeMappingMethods, afterMappingMethods); }