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 Summary
Modifier and TypeMethodDescriptiondefault ManifestResourcemanifest()Manifest resource that is used to collect all manifest files to allow runtime discovery.default FilerResourceA text resource that can be updated in the output.default voidservices(TypeName generator, TypeName providerInterface, List<TypeName> providers, Object... originatingElements) Write aMETA-INF/servicesfile for a specific provider interface and implementation(s).default FilerTextResourcetextResource(String location, Object... originatingElements) A text resource that can be updated in the output.writeResource(byte[] resource, String location, Object... originatingElements) Write a resource file.writeSourceFile(ClassModel classModel, Object... originatingElements) Write a source file from itsClassModel.writeSourceFile(TypeName type, String content, Object... originatingElements) Write a source file using string content.
-
Method Details
-
writeSourceFile
Write a source file from itsClassModel.- Parameters:
classModel- class model to write outoriginatingElements- elements that caused this type to be generated (you can useTypeInfoBlueprint.originatingElementValue())- Returns:
- written path, we expect to always run on local file system
-
writeSourceFile
Write a source file using string content.- Parameters:
type- type of the file to generatecontent- source code to writeoriginatingElements- elements that caused this type to be generated- Returns:
- written path, we expect to always run on local file system
-
writeResource
Write a resource file.- Parameters:
resource- bytes of the resource filelocation- location to write to in the classes output directoryoriginatingElements- elements that caused this file to be generated- Returns:
- written path, we expect to always run on local file system
-
textResource
A text resource that can be updated in the output. Note that the resource can only be written once per processing round.- Parameters:
location- location to read/write to in the classes output directoryoriginatingElements- elements that caused this file to be generated- Returns:
- the resource that can be used to update the file
-
resource
A text resource that can be updated in the output. Note that the resource can only be written once per processing round.- Parameters:
location- location to read/write to in the classes output directoryoriginatingElements- elements that caused this file to be generated- Returns:
- the resource that can be used to update the file
-
manifest
Manifest resource that is used to collect all manifest files to allow runtime discovery.- Returns:
- manifest resource
-
services
default void services(TypeName generator, TypeName providerInterface, List<TypeName> providers, Object... originatingElements) Write aMETA-INF/servicesfile 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 fileoriginatingElements- elements that caused this type to be generated
-