-
Notifications
You must be signed in to change notification settings - Fork 1
AnnotationProcessing_Configurer
Ladislav Gazo edited this page Aug 29, 2015
·
1 revision
Using @SupportedAnnotationTypes annotation (used mainly to support all annotations using asterix "*")
@SupportedAnnotationTypes("sk.seges.sesam.core.annotation.CustomAnnotation")
@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class SesamProcessor extends AbstractProcessor {
}
or using getSupportedAnnotationTypes method (in order to have type safe code)
@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class SesamProcessor extends AbstractProcessor {
@Override
public Set<String> getSupportedAnnotationTypes() {
Set<String> annotations = new HashSet<String>();
annotations.add(CustomAnnotation.class.getCanonicalName());
return annotations;
}
}
public class SesamProcessorConfigurer extends DefaultProcessorConfigurer {
@Override
protected Type[] getConfigurationElement(DefaultConfigurationElement element) {
switch (element) {
case PROCESSING_ANNOTATIONS:
return new Type[] {
CustomAnnotation.class
};
}
return new Type[] {};
}
}
@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class SesamProcessor extends MutableAnnotationProcessor {
@Override
protected ProcessorConfigurer getConfigurer() {
return new SesamProcessorConfigurer();
}
}