mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#34 Accessing annotation in a safer way
This commit is contained in:
parent
a7be616ee9
commit
217562d52b
@ -37,10 +37,10 @@ public class DefaultMapperReference extends AbstractModelElement implements Mapp
|
||||
private final boolean isAnnotatedMapper;
|
||||
private final Set<Type> importTypes;
|
||||
|
||||
public DefaultMapperReference(Type type, TypeFactory typeFactory) {
|
||||
public DefaultMapperReference(Type type, boolean isAnnotatedMapper, TypeFactory typeFactory) {
|
||||
this.type = type;
|
||||
|
||||
isAnnotatedMapper = type.isAnnotatedWith( "org.mapstruct.Mapper" );
|
||||
this.isAnnotatedMapper = isAnnotatedMapper;
|
||||
importTypes = Collections.asSet( type );
|
||||
|
||||
if ( isAnnotatedMapper() ) {
|
||||
|
@ -148,7 +148,13 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Metho
|
||||
MapperPrism mapperPrism = MapperPrism.getInstanceOn( element );
|
||||
|
||||
for ( TypeMirror usedMapper : mapperPrism.uses() ) {
|
||||
mapperReferences.add( new DefaultMapperReference( typeFactory.getType( usedMapper ), typeFactory ) );
|
||||
mapperReferences.add(
|
||||
new DefaultMapperReference(
|
||||
typeFactory.getType( usedMapper ),
|
||||
MapperPrism.getInstanceOn( typeUtils.asElement( usedMapper ) ) != null,
|
||||
typeFactory
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return mapperReferences;
|
||||
|
Loading…
x
Reference in New Issue
Block a user