Polish after PR merge

* Extract common TypeMirror extraction into a separate method
* Remove not needed code from tests
This commit is contained in:
Filip Hrisafov 2017-11-23 23:51:18 +01:00
parent faabbf7ec0
commit 1af702e44b
4 changed files with 14 additions and 32 deletions

View File

@ -380,28 +380,24 @@ public class TypeFactory {
}
public List<Type> getThrownTypes(ExecutableType method) {
List<Type> thrownTypes = new ArrayList<Type>();
for ( TypeMirror exceptionType : method.getThrownTypes() ) {
Type t = getType( exceptionType );
if (!thrownTypes.contains( t )) {
thrownTypes.add( t );
}
}
return thrownTypes;
return extractTypes( method.getThrownTypes() );
}
public List<Type> getThrownTypes(Accessor accessor) {
if (accessor.getExecutable() == null) {
return new ArrayList<Type>();
}
List<Type> thrownTypes = new ArrayList<Type>();
for (TypeMirror thrownType : accessor.getExecutable().getThrownTypes()) {
Type t = getType( thrownType );
if (!thrownTypes.contains( t )) {
thrownTypes.add( t );
}
return extractTypes( accessor.getExecutable().getThrownTypes() );
}
private List<Type> extractTypes(List<? extends TypeMirror> typeMirrors) {
Set<Type> types = new HashSet<Type>( typeMirrors.size() );
for ( TypeMirror typeMirror : typeMirrors ) {
types.add( getType( typeMirror ) );
}
return thrownTypes;
return new ArrayList<Type>( types );
}
private List<Type> getTypeParameters(TypeMirror mirror, boolean isImplementationType) {

View File

@ -23,8 +23,4 @@ package org.mapstruct.ap.test.nestedsource.exceptions;
* @author Richard Lea <chigix@zoho.com>
*/
public class NoSuchUser extends Exception {
public NoSuchUser() {
}
}

View File

@ -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 <chigix@zoho.com>
*/
@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;
}

View File

@ -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() {