- java.lang.Object
-
- javax.annotation.processing.AbstractProcessor
-
- All Implemented Interfaces:
- Processor
public abstract class AbstractProcessor extends Object implements Processor
An abstract annotation processor designed to be a convenient superclass for most concrete annotation processors. This class examines annotation values to compute the options, annotations, and source version supported by its subtypes.The getter methods may issue warnings about noteworthy conditions using the facilities available after the processor has been initialized.
Subclasses are free to override the implementation and specification of any of the methods in this class as long as the general
Processor
contract for that method is obeyed.- Since:
- 1.6
-
-
Field Summary
Fields Modifier and Type Field and Description protected ProcessingEnvironment
processingEnv
Processing environment providing by the tool framework.
-
Constructor Summary
Constructors Modifier Constructor and Description protected
AbstractProcessor()
Constructor for subclasses to call.
-
Method Summary
Methods Modifier and Type Method and Description Iterable<? extends Completion>
getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText)
Returns an empty iterable of completions.Set<String>
getSupportedAnnotationTypes()
If the processor class is annotated withSupportedAnnotationTypes
, return an unmodifiable set with the same set of strings as the annotation.Set<String>
getSupportedOptions()
If the processor class is annotated withSupportedOptions
, return an unmodifiable set with the same set of strings as the annotation.SourceVersion
getSupportedSourceVersion()
If the processor class is annotated withSupportedSourceVersion
, return the source version in the annotation.void
init(ProcessingEnvironment processingEnv)
Initializes the processor with the processing environment by setting theprocessingEnv
field to the value of theprocessingEnv
argument.protected boolean
isInitialized()
abstract boolean
process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)
Processes a set of annotation types on type elements originating from the prior round and returns whether or not these annotations are claimed by this processor.
-
-
-
Field Detail
-
processingEnv
protected ProcessingEnvironment processingEnv
Processing environment providing by the tool framework.
-
-
Constructor Detail
-
AbstractProcessor
protected AbstractProcessor()
Constructor for subclasses to call.
-
-
Method Detail
-
getSupportedOptions
public Set<String> getSupportedOptions()
If the processor class is annotated withSupportedOptions
, return an unmodifiable set with the same set of strings as the annotation. If the class is not so annotated, an empty set is returned.- Specified by:
getSupportedOptions
in interfaceProcessor
- Returns:
- the options recognized by this processor, or an empty set if none
- See Also:
SupportedOptions
-
getSupportedAnnotationTypes
public Set<String> getSupportedAnnotationTypes()
If the processor class is annotated withSupportedAnnotationTypes
, return an unmodifiable set with the same set of strings as the annotation. If the class is not so annotated, an empty set is returned.- Specified by:
getSupportedAnnotationTypes
in interfaceProcessor
- Returns:
- the names of the annotation types supported by this processor, or an empty set if none
- See Also:
SupportedAnnotationTypes
-
getSupportedSourceVersion
public SourceVersion getSupportedSourceVersion()
If the processor class is annotated withSupportedSourceVersion
, return the source version in the annotation. If the class is not so annotated,SourceVersion.RELEASE_6
is returned.- Specified by:
getSupportedSourceVersion
in interfaceProcessor
- Returns:
- the latest source version supported by this processor
- See Also:
SupportedSourceVersion
,ProcessingEnvironment.getSourceVersion()
-
init
public void init(ProcessingEnvironment processingEnv)
Initializes the processor with the processing environment by setting theprocessingEnv
field to the value of theprocessingEnv
argument. AnIllegalStateException
will be thrown if this method is called more than once on the same object.- Specified by:
init
in interfaceProcessor
- Parameters:
processingEnv
- environment to access facilities the tool framework provides to the processor- Throws:
IllegalStateException
- if this method is called more than once.
-
process
public abstract boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)
Processes a set of annotation types on type elements originating from the prior round and returns whether or not these annotations are claimed by this processor. Iftrue
is returned, the annotations are claimed and subsequent processors will not be asked to process them; iffalse
is returned, the annotations are unclaimed and subsequent processors may be asked to process them. A processor may always return the same boolean value or may vary the result based on chosen criteria.The input set will be empty if the processor supports
"*"
and the root elements have no annotations. AProcessor
must gracefully handle an empty set of annotations.
-
getCompletions
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText)
Returns an empty iterable of completions.- Specified by:
getCompletions
in interfaceProcessor
- Parameters:
element
- the element being annotatedannotation
- the (perhaps partial) annotation being applied to the elementmember
- the annotation member to return possible completions foruserText
- source code text to be completed- Returns:
- suggested completions to the annotation
-
isInitialized
protected boolean isInitialized()
- Returns:
true
if this object has been initialized,false
otherwise.
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/annotation/processing/AbstractProcessor.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.