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) {
|
public List<Type> getThrownTypes(ExecutableType method) {
|
||||||
List<Type> thrownTypes = new ArrayList<Type>();
|
return extractTypes( method.getThrownTypes() );
|
||||||
for ( TypeMirror exceptionType : method.getThrownTypes() ) {
|
|
||||||
Type t = getType( exceptionType );
|
|
||||||
if (!thrownTypes.contains( t )) {
|
|
||||||
thrownTypes.add( t );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return thrownTypes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Type> getThrownTypes(Accessor accessor) {
|
public List<Type> getThrownTypes(Accessor accessor) {
|
||||||
if (accessor.getExecutable() == null) {
|
if (accessor.getExecutable() == null) {
|
||||||
return new ArrayList<Type>();
|
return new ArrayList<Type>();
|
||||||
}
|
}
|
||||||
List<Type> thrownTypes = new ArrayList<Type>();
|
return extractTypes( accessor.getExecutable().getThrownTypes() );
|
||||||
for (TypeMirror thrownType : accessor.getExecutable().getThrownTypes()) {
|
}
|
||||||
Type t = getType( thrownType );
|
|
||||||
if (!thrownTypes.contains( t )) {
|
private List<Type> extractTypes(List<? extends TypeMirror> typeMirrors) {
|
||||||
thrownTypes.add( t );
|
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) {
|
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>
|
* @author Richard Lea <chigix@zoho.com>
|
||||||
*/
|
*/
|
||||||
public class NoSuchUser extends Exception {
|
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.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
import org.mapstruct.Mappings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Richard Lea <chigix@zoho.com>
|
* @author Richard Lea <chigix@zoho.com>
|
||||||
*/
|
*/
|
||||||
@Mapper()
|
@Mapper
|
||||||
public interface ResourceMapper {
|
public interface ResourceMapper {
|
||||||
|
|
||||||
@Mappings({
|
@Mapping(source = "bucket.user.uuid", target = "userId")
|
||||||
@Mapping(source = "bucket.user.uuid", target = "userId")
|
|
||||||
})
|
|
||||||
ResourceDto map(Resource r) throws NoSuchUser;
|
ResourceDto map(Resource r) throws NoSuchUser;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,15 +26,8 @@ public class User {
|
|||||||
|
|
||||||
private final String uuid;
|
private final String uuid;
|
||||||
|
|
||||||
private final String name;
|
public User(String uuid) {
|
||||||
|
|
||||||
public User(String uuid, String name) {
|
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUuid() {
|
public String getUuid() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user