Interface CodegenFiler


public interface CodegenFiler
An abstraction for writing out source files and resource files. Always attempts to create a new file and replace its content (as it is impossible to update files in annotation processing).
  • Method Details

    • writeSourceFile

      Path writeSourceFile(ClassModel classModel, Object... originatingElements)
      Write a source file from its ClassModel.
      Parameters:
      classModel - class model to write out
      originatingElements - elements that caused this type to be generated (you can use TypeInfoBlueprint.originatingElement() for example
      Returns:
      written path, we expect to always run on local file system
    • writeResource

      Path writeResource(byte[] resource, String location, Object... originatingElements)
      Write a resource file.
      Parameters:
      resource - bytes of the resource file
      location - location to write to in the classes output directory
      originatingElements - elements that caused this type to be generated
      Returns:
      written path, we expect to always run on local file system
    • services

      default void services(TypeName generator, TypeName providerInterface, List<TypeName> providers, Object... originatingElements)
      Write a META-INF/services file for a specific provider interface and implementation(s).
      Parameters:
      generator - type of the generator (to mention in the generated code)
      providerInterface - type of the provider interface (and also name of the file to be generated)
      providers - list of provider implementations to add to the file
      originatingElements - elements that caused this type to be generated