mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#544 targetType should not be added to imports in case of an update method selection
This commit is contained in:
parent
ac1f9aeaa5
commit
f69f035bd5
@ -253,7 +253,7 @@ public class PropertyMapping extends ModelElement {
|
||||
}
|
||||
Assignment factoryMethod =
|
||||
ctx.getMappingResolver().getFactoryMethod( method, targetType, null, null );
|
||||
result = new UpdateWrapper( result, method.getThrownTypes(), targetType, factoryMethod );
|
||||
result = new UpdateWrapper( result, method.getThrownTypes(), factoryMethod );
|
||||
}
|
||||
else {
|
||||
result = new SetterWrapper( result, method.getThrownTypes() );
|
||||
@ -579,8 +579,7 @@ public class PropertyMapping extends ModelElement {
|
||||
}
|
||||
Assignment factoryMethod =
|
||||
ctx.getMappingResolver().getFactoryMethod( method, targetType, null, null );
|
||||
assignment =
|
||||
new UpdateWrapper( assignment, method.getThrownTypes(), targetType, factoryMethod );
|
||||
assignment = new UpdateWrapper( assignment, method.getThrownTypes(), factoryMethod );
|
||||
}
|
||||
else {
|
||||
assignment = new SetterWrapper( assignment, method.getThrownTypes() );
|
||||
|
@ -19,9 +19,7 @@
|
||||
package org.mapstruct.ap.model.assignment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.mapstruct.ap.model.common.Type;
|
||||
|
||||
/**
|
||||
@ -32,14 +30,12 @@ import org.mapstruct.ap.model.common.Type;
|
||||
public class UpdateWrapper extends AssignmentWrapper {
|
||||
|
||||
private final List<Type> exceptionTypesToExclude;
|
||||
private final Type targetType;
|
||||
private final Assignment factoryMethod;
|
||||
|
||||
public UpdateWrapper(Assignment decoratedAssignment, List<Type> exceptionTypesToExclude, Type targetType,
|
||||
Assignment factoryMethod ) {
|
||||
public UpdateWrapper(Assignment decoratedAssignment, List<Type> exceptionTypesToExclude,
|
||||
Assignment factoryMethod ) {
|
||||
super( decoratedAssignment );
|
||||
this.exceptionTypesToExclude = exceptionTypesToExclude;
|
||||
this.targetType = targetType;
|
||||
this.factoryMethod = factoryMethod;
|
||||
}
|
||||
|
||||
@ -57,14 +53,6 @@ public class UpdateWrapper extends AssignmentWrapper {
|
||||
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() {
|
||||
return factoryMethod;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user