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 FilerResource
A text resource that can be updated in the output.default void
services
(TypeName generator, TypeName providerInterface, List<TypeName> providers, Object... originatingElements) Write aMETA-INF/services
file for a specific provider interface and implementation(s).default FilerTextResource
textResource
(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
.
-
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.originatingElement()
for example- 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
-
services
default void services(TypeName generator, TypeName providerInterface, List<TypeName> providers, Object... originatingElements) Write aMETA-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 fileoriginatingElements
- elements that caused this type to be generated
-