#297 check presence of @Mapper annotation

This commit is contained in:
Christian Schuster 2014-09-23 21:40:05 +02:00 committed by Gunnar Morling
parent 33abe5faaf
commit 2ca4ce5fd5

View File

@ -42,6 +42,7 @@ import javax.tools.Diagnostic.Kind;
import org.mapstruct.ap.model.Mapper;
import org.mapstruct.ap.option.Options;
import org.mapstruct.ap.option.ReportingPolicy;
import org.mapstruct.ap.prism.MapperPrism;
import org.mapstruct.ap.processor.DefaultModelElementProcessorContext;
import org.mapstruct.ap.processor.ModelElementProcessor;
import org.mapstruct.ap.processor.ModelElementProcessor.ProcessorContext;
@ -134,6 +135,12 @@ public class MappingProcessor extends AbstractProcessor {
for ( Element mapperElement : roundEnvironment.getElementsAnnotatedWith( annotation ) ) {
TypeElement mapperTypeElement = asTypeElement( mapperElement );
// on some JDKs, RoundEnvironment.getElementsAnnotatedWith( ... ) returns types with
// annotations unknown to the compiler, even though they are not declared Mappers
if ( MapperPrism.getInstanceOn( mapperTypeElement ) == null ) {
continue;
}
// create a new context for each generated mapper in order to have imports of referenced types
// correctly managed;
// note that this assumes that a new source file is created for each mapper which must not