#34 Accessing annotation in a safer way

This commit is contained in:
Gunnar Morling 2014-01-09 21:45:01 +01:00
parent a7be616ee9
commit 217562d52b
2 changed files with 9 additions and 3 deletions

View File

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

View File

@ -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;