diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/common/TypeFactory.java b/processor/src/main/java/org/mapstruct/ap/internal/model/common/TypeFactory.java index 062d67fa6..964bb79c0 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/common/TypeFactory.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/common/TypeFactory.java @@ -380,28 +380,24 @@ public class TypeFactory { } public List getThrownTypes(ExecutableType method) { - List thrownTypes = new ArrayList(); - for ( TypeMirror exceptionType : method.getThrownTypes() ) { - Type t = getType( exceptionType ); - if (!thrownTypes.contains( t )) { - thrownTypes.add( t ); - } - } - return thrownTypes; + return extractTypes( method.getThrownTypes() ); } public List getThrownTypes(Accessor accessor) { if (accessor.getExecutable() == null) { return new ArrayList(); } - List thrownTypes = new ArrayList(); - for (TypeMirror thrownType : accessor.getExecutable().getThrownTypes()) { - Type t = getType( thrownType ); - if (!thrownTypes.contains( t )) { - thrownTypes.add( t ); - } + return extractTypes( accessor.getExecutable().getThrownTypes() ); + } + + private List extractTypes(List typeMirrors) { + Set types = new HashSet( typeMirrors.size() ); + + for ( TypeMirror typeMirror : typeMirrors ) { + types.add( getType( typeMirror ) ); } - return thrownTypes; + + return new ArrayList( types ); } private List getTypeParameters(TypeMirror mirror, boolean isImplementationType) { diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedsource/exceptions/NoSuchUser.java b/processor/src/test/java/org/mapstruct/ap/test/nestedsource/exceptions/NoSuchUser.java index a7e21a480..0a8044639 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/nestedsource/exceptions/NoSuchUser.java +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedsource/exceptions/NoSuchUser.java @@ -23,8 +23,4 @@ package org.mapstruct.ap.test.nestedsource.exceptions; * @author Richard Lea */ public class NoSuchUser extends Exception { - - public NoSuchUser() { - } - } diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedsource/exceptions/ResourceMapper.java b/processor/src/test/java/org/mapstruct/ap/test/nestedsource/exceptions/ResourceMapper.java index 86c43b48f..0b8b706ca 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/nestedsource/exceptions/ResourceMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedsource/exceptions/ResourceMapper.java @@ -20,18 +20,15 @@ package org.mapstruct.ap.test.nestedsource.exceptions; import org.mapstruct.Mapper; import org.mapstruct.Mapping; -import org.mapstruct.Mappings; /** * * @author Richard Lea */ -@Mapper() +@Mapper public interface ResourceMapper { - @Mappings({ - @Mapping(source = "bucket.user.uuid", target = "userId") - }) + @Mapping(source = "bucket.user.uuid", target = "userId") ResourceDto map(Resource r) throws NoSuchUser; } diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedsource/exceptions/User.java b/processor/src/test/java/org/mapstruct/ap/test/nestedsource/exceptions/User.java index b7c81e33f..0f7724b81 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/nestedsource/exceptions/User.java +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedsource/exceptions/User.java @@ -26,15 +26,8 @@ public class User { private final String uuid; - private final String name; - - public User(String uuid, String name) { + public User(String uuid) { this.uuid = uuid; - this.name = name; - } - - public String getName() { - return name; } public String getUuid() {