Interface RoundContext

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 Details

    • availableAnnotations

      Collection<TypeName> availableAnnotations()
      Annotations available in this round, the collection contains only annotations valid for the extension being invoked.
      available annotations
    • types

      All types that are processed in this round. Only contains types that are valid for processing by this extension.
      matching types
    • annotatedTypes

      Collection<TypeInfo> annotatedTypes(TypeName annotationType)
      All types annotated with a specific annotation.
      annotationType - annotation to check
      types that contain the annotation
    • annotatedElements

      Collection<TypedElementInfo> annotatedElements(TypeName annotationType)
      All elements annotated with a specific annotation.
      annotationType - annotation to check
      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.

      type - type of the new class
      newClass - builder of the new class
      mainTrigger - a type that caused this, may be the processor itself, if not bound to any type
      originatingElements - possible originating elements (such as Element in APT, or ClassInfo in classpath scanning)
    • generatedType

      Optional<ClassModel.Builder> generatedType(TypeName type)
      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 its CodegenExtensionProvider weight.
      type - type of the generated type
      class model of the new type if any