You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ladislav Gazo edited this page Aug 29, 2015
·
1 revision
The "standard way"
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;
}
}
Using configurers
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();
}
}