public interface RoundContext
Context of a single round of code generation.
For example the first round may generate types, that require additional code generation.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addGeneratedType
(TypeName type, ClassModel.Builder newClass, TypeName mainTrigger, Object... originatingElements) Add a new class to be code generated.annotatedElements
(TypeName annotationType) All elements annotated with a specific annotation.annotatedTypes
(TypeName annotationType) All types annotated with a specific annotation (including types that inherit such annotation from super types or through interfaces).Annotations available in this round, the collection contains only annotations valid for the extension being invoked.generatedType
(TypeName type) Class model builder for a type that is to be code generated.types()
All types that are processed in this round.
-
Method Details
-
availableAnnotations
Collection<TypeName> availableAnnotations()Annotations available in this round, the collection contains only annotations valid for the extension being invoked.- Returns:
- available annotations
-
types
Collection<TypeInfo> types()All types that are processed in this round. Only contains types that are valid for processing by this extension.- Returns:
- matching types
-
annotatedTypes
All types annotated with a specific annotation (including types that inherit such annotation from super types or through interfaces).- Parameters:
annotationType
- annotation to check- Returns:
- types that contain the annotation
-
annotatedElements
All elements annotated with a specific annotation.- Parameters:
annotationType
- annotation to check- Returns:
- elements that contain the annotation
-
addGeneratedType
void addGeneratedType(TypeName type, ClassModel.Builder newClass, TypeName mainTrigger, Object... originatingElements) Add a new class to be code generated.Actual code generation will be done once, at the end of this round. Note that you can always force immediate generation through
CodegenContext.filer()
. In such a case do not add the type through this method. If you call this method with a type that was already registered, you will replace that instance.- Parameters:
type
- type of the new classnewClass
- builder of the new classmainTrigger
- a type that caused this, may be the processor itself, if not bound to any typeoriginatingElements
- possible originating elements (such as Element in APT, or ClassInfo in classpath scanning)
-
generatedType
Class model builder for a type that is to be code generated. This method provides access to all types that are to be generated, even from other extensions that do not match annotations. Whether another extension was already called depends on itsCodegenExtensionProvider
weight.- Parameters:
type
- type of the generated type- Returns:
- class model of the new type if any
-