Package org.springframework.aot.generate
Interface GeneratedFiles
- All Known Implementing Classes:
FileSystemGeneratedFiles
,InMemoryGeneratedFiles
public interface GeneratedFiles
Repository of generated files. Can be used to add
source
,
resource
, or class
files generated
during ahead-of-time processing. Source and resource files are written using
UTF-8
encoding.- Since:
- 6.0
- Author:
- Phillip Webb, Brian Clozel, Stephane Nicoll
- See Also:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Provide access to a particular file and offer convenient methods to retrieve, save, or override its content.static enum
The various kinds of generated files that are supported. -
Method Summary
Modifier and TypeMethodDescriptiondefault void
addClassFile
(String path, InputStreamSource content) Add a generatedclass file
with content from the givenInputStreamSource
.default void
addFile
(GeneratedFiles.Kind kind, String path, CharSequence content) Add a generated file of the specifiedGeneratedFiles.Kind
with content from the givenCharSequence
.default void
addFile
(GeneratedFiles.Kind kind, String path, InputStreamSource content) Add a generated file of the specifiedGeneratedFiles.Kind
with content from the givenInputStreamSource
.default void
addFile
(GeneratedFiles.Kind kind, String path, ThrowingConsumer<Appendable> content) Add a generated file of the specifiedGeneratedFiles.Kind
with content written to anAppendable
passed to the givenThrowingConsumer
.default void
addResourceFile
(String path, CharSequence content) Add a generatedresource file
with content from the givenCharSequence
.default void
addResourceFile
(String path, InputStreamSource content) Add a generatedresource file
with content from the givenInputStreamSource
.default void
addResourceFile
(String path, ThrowingConsumer<Appendable> content) Add a generatedresource file
with content written to anAppendable
passed to the givenThrowingConsumer
.default void
addSourceFile
(String className, CharSequence content) Add a generatedsource file
with content from the givenCharSequence
.default void
addSourceFile
(String className, InputStreamSource content) Add a generatedsource file
with content from the givenInputStreamSource
.default void
addSourceFile
(String className, ThrowingConsumer<Appendable> content) Add a generatedsource file
with content written to anAppendable
passed to the givenThrowingConsumer
.default void
addSourceFile
(org.springframework.javapoet.JavaFile javaFile) Add a generatedsource file
with content from the givenJavaFile
.void
handleFile
(GeneratedFiles.Kind kind, String path, ThrowingConsumer<GeneratedFiles.FileHandler> handler) Handle a generated file of the specifiedGeneratedFiles.Kind
with the given handler.
-
Method Details
-
addSourceFile
default void addSourceFile(org.springframework.javapoet.JavaFile javaFile) Add a generatedsource file
with content from the givenJavaFile
.- Parameters:
javaFile
- the java file to add
-
addSourceFile
Add a generatedsource file
with content from the givenCharSequence
.- Parameters:
className
- the class name that should be used to determine the path of the filecontent
- the contents of the file
-
addSourceFile
Add a generatedsource file
with content written to anAppendable
passed to the givenThrowingConsumer
.- Parameters:
className
- the class name that should be used to determine the path of the filecontent
- aThrowingConsumer
that accepts anAppendable
which will receive the file contents
-
addSourceFile
Add a generatedsource file
with content from the givenInputStreamSource
.- Parameters:
className
- the class name that should be used to determine the path of the filecontent
- anInputStreamSource
that will provide an input stream containing the file contents
-
addResourceFile
Add a generatedresource file
with content from the givenCharSequence
.- Parameters:
path
- the relative path of the filecontent
- the contents of the file
-
addResourceFile
Add a generatedresource file
with content written to anAppendable
passed to the givenThrowingConsumer
.- Parameters:
path
- the relative path of the filecontent
- aThrowingConsumer
that accepts anAppendable
which will receive the file contents
-
addResourceFile
Add a generatedresource file
with content from the givenInputStreamSource
.- Parameters:
path
- the relative path of the filecontent
- anInputStreamSource
that will provide an input stream containing the file contents
-
addClassFile
Add a generatedclass file
with content from the givenInputStreamSource
.- Parameters:
path
- the relative path of the filecontent
- anInputStreamSource
that will provide an input stream containing the file contents
-
addFile
Add a generated file of the specifiedGeneratedFiles.Kind
with content from the givenCharSequence
.- Parameters:
kind
- the kind of file being writtenpath
- the relative path of the filecontent
- the contents of the file
-
addFile
Add a generated file of the specifiedGeneratedFiles.Kind
with content written to anAppendable
passed to the givenThrowingConsumer
.- Parameters:
kind
- the kind of file being writtenpath
- the relative path of the filecontent
- aThrowingConsumer
that accepts anAppendable
which will receive the file contents
-
addFile
Add a generated file of the specifiedGeneratedFiles.Kind
with content from the givenInputStreamSource
.- Parameters:
kind
- the kind of file being writtenpath
- the relative path of the filecontent
- anInputStreamSource
that will provide an input stream containing the file contents
-
handleFile
void handleFile(GeneratedFiles.Kind kind, String path, ThrowingConsumer<GeneratedFiles.FileHandler> handler) Handle a generated file of the specifiedGeneratedFiles.Kind
with the given handler. The file handler lets you consume the content of the already generated file, if any and provide a way to override its content if necessary.- Parameters:
kind
- the kind of filepath
- the relative path of the filehandler
- a consumer of aGeneratedFiles.FileHandler
for the file- Since:
- 6.2
-