#544 targetType should not be added to imports in case of an update method selection

This commit is contained in:
sjaakd 2015-05-17 20:34:57 +02:00
parent ac1f9aeaa5
commit f69f035bd5
2 changed files with 4 additions and 17 deletions

View File

@ -253,7 +253,7 @@ public class PropertyMapping extends ModelElement {
} }
Assignment factoryMethod = Assignment factoryMethod =
ctx.getMappingResolver().getFactoryMethod( method, targetType, null, null ); ctx.getMappingResolver().getFactoryMethod( method, targetType, null, null );
result = new UpdateWrapper( result, method.getThrownTypes(), targetType, factoryMethod ); result = new UpdateWrapper( result, method.getThrownTypes(), factoryMethod );
} }
else { else {
result = new SetterWrapper( result, method.getThrownTypes() ); result = new SetterWrapper( result, method.getThrownTypes() );
@ -579,8 +579,7 @@ public class PropertyMapping extends ModelElement {
} }
Assignment factoryMethod = Assignment factoryMethod =
ctx.getMappingResolver().getFactoryMethod( method, targetType, null, null ); ctx.getMappingResolver().getFactoryMethod( method, targetType, null, null );
assignment = assignment = new UpdateWrapper( assignment, method.getThrownTypes(), factoryMethod );
new UpdateWrapper( assignment, method.getThrownTypes(), targetType, factoryMethod );
} }
else { else {
assignment = new SetterWrapper( assignment, method.getThrownTypes() ); assignment = new SetterWrapper( assignment, method.getThrownTypes() );

View File

@ -19,9 +19,7 @@
package org.mapstruct.ap.model.assignment; package org.mapstruct.ap.model.assignment;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import org.mapstruct.ap.model.common.Type; import org.mapstruct.ap.model.common.Type;
/** /**
@ -32,14 +30,12 @@ import org.mapstruct.ap.model.common.Type;
public class UpdateWrapper extends AssignmentWrapper { public class UpdateWrapper extends AssignmentWrapper {
private final List<Type> exceptionTypesToExclude; private final List<Type> exceptionTypesToExclude;
private final Type targetType;
private final Assignment factoryMethod; private final Assignment factoryMethod;
public UpdateWrapper(Assignment decoratedAssignment, List<Type> exceptionTypesToExclude, Type targetType, public UpdateWrapper(Assignment decoratedAssignment, List<Type> exceptionTypesToExclude,
Assignment factoryMethod ) { Assignment factoryMethod ) {
super( decoratedAssignment ); super( decoratedAssignment );
this.exceptionTypesToExclude = exceptionTypesToExclude; this.exceptionTypesToExclude = exceptionTypesToExclude;
this.targetType = targetType;
this.factoryMethod = factoryMethod; this.factoryMethod = factoryMethod;
} }
@ -57,14 +53,6 @@ public class UpdateWrapper extends AssignmentWrapper {
return result; return result;
} }
@Override
public Set<Type> getImportTypes() {
Set<Type> imported = new HashSet<Type>();
imported.addAll( super.getImportTypes() );
imported.add( targetType ); /* is a new target type */
return imported;
}
public Assignment getFactoryMethod() { public Assignment getFactoryMethod() {
return factoryMethod; return factoryMethod;
} }