mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
Polish after PR merge
* Extract common TypeMirror extraction into a separate method * Remove not needed code from tests
This commit is contained in:
parent
faabbf7ec0
commit
1af702e44b
@ -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) {
|
||||
|
@ -23,8 +23,4 @@ package org.mapstruct.ap.test.nestedsource.exceptions;
|
||||
* @author Richard Lea <chigix@zoho.com>
|
||||
*/
|
||||
public class NoSuchUser extends Exception {
|
||||
|
||||
public NoSuchUser() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user