@AutoService(value=javax.annotation.processing.Processor.class)
public final class GlideAnnotationProcessor
extends javax.annotation.processing.AbstractProcessor
This processor discovers all AppGlideModule
and
LibraryGlideModule
implementations that are
annotated with GlideModule
. Any implementations missing the
annotation will be ignored.
This processor also discovers all GlideExtension
annotated classes.
Multiple classes are generated by this processor:
LibraryGlideModule
s - A GlideIndexer class in a
specific package that will later be used by the processor to discover all
LibraryGlideModule
classes.
AppGlideModule
s - A single
AppGlideModule
implementation
(com.bumptech.glide.GeneratedAppGlideModule
) that calls all
LibraryGlideModule
s and the
original AppGlideModule
in the correct order when Glide is
initialized.
GlideExtension
s -
com.bumptech.glide.request.RequestOptions
implementation that contains
static versions of all builder methods in the base class and both static and instance
versions of methods in all GlideExtension
s.
GlideExtension
annotated classes are annotated with
GlideType
:
com.bumptech.glide.RequestManager
implementation containing a generated
method for each method annotated with
GlideType
.
com.bumptech.glide.manager.RequestManagerRetriever.RequestManagerFactory
implementation that produces the generated com.bumptech.glide.RequestManager
s.
com.bumptech.glide.Glide
look-alike that implements all static methods in
the com.bumptech.glide.Glide
singleton and returns the generated
com.bumptech.glide.RequestManager
implementation when appropriate.
AppGlideModule
implementations must only be included in
applications, not in libraries. There must be exactly one
AppGlideModule
implementation per
Application. The AppGlideModule
class is
used as a signal that all modules have been found and that the final merged
com.bumptech.glide.GeneratedAppGlideModule
impl can be created.
Constructor and Description |
---|
GlideAnnotationProcessor() |
Modifier and Type | Method and Description |
---|---|
Set<String> |
getSupportedAnnotationTypes() |
javax.lang.model.SourceVersion |
getSupportedSourceVersion() |
void |
init(javax.annotation.processing.ProcessingEnvironment processingEnvironment) |
boolean |
process(Set<? extends javax.lang.model.element.TypeElement> set,
javax.annotation.processing.RoundEnvironment env)
Each round we do the following:
Find all
AppGlideModule s and save them to an instance variable (throw if > 1). |
public void init(javax.annotation.processing.ProcessingEnvironment processingEnvironment)
init
in interface javax.annotation.processing.Processor
init
in class javax.annotation.processing.AbstractProcessor
public Set<String> getSupportedAnnotationTypes()
getSupportedAnnotationTypes
in interface javax.annotation.processing.Processor
getSupportedAnnotationTypes
in class javax.annotation.processing.AbstractProcessor
public javax.lang.model.SourceVersion getSupportedSourceVersion()
getSupportedSourceVersion
in interface javax.annotation.processing.Processor
getSupportedSourceVersion
in class javax.annotation.processing.AbstractProcessor
public boolean process(Set<? extends javax.lang.model.element.TypeElement> set, javax.annotation.processing.RoundEnvironment env)
AppGlideModule
s and save them to an instance variable (throw if > 1).
LibraryGlideModule
s
LibraryGlideModule
,
write an Indexer
with an Annotation with the class name.
Indexer
s, return and wait for the next round.
Indexer
s and there is a AppGlideModule
,
write the GeneratedAppGlideModule
.
Once the GeneratedAppGlideModule
is written, we expect to be finished.
Any further generation of related classes will result in errors.
process
in interface javax.annotation.processing.Processor
process
in class javax.annotation.processing.AbstractProcessor