Package org.springframework.aot.generate
Class GeneratedFiles
java.lang.Object
org.springframework.aot.generate.GeneratedFiles
- Direct Known Subclasses:
FileSystemGeneratedFiles
,InMemoryGeneratedFiles
Interface that 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
Nested ClassesModifier and TypeClassDescriptionstatic class
Provide access to a particular file and offer convenient method to save or override its content.static enum
The various kinds of generated files that are supported. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addClassFile
(String path, InputStreamSource content) Add a generatedclass file
with content from the givenInputStreamSource
.void
addFile
(GeneratedFiles.Kind kind, String path, CharSequence content) Add a generated file of the specifiedGeneratedFiles.Kind
with content from the givenCharSequence
.void
addFile
(GeneratedFiles.Kind kind, String path, InputStreamSource content) Add a generated file of the specifiedGeneratedFiles.Kind
with content from the givenInputStreamSource
.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
.void
addResourceFile
(String path, CharSequence content) Add a generatedresource file
with content from the givenCharSequence
.void
addResourceFile
(String path, InputStreamSource content) Add a generatedresource file
with content from the givenInputStreamSource
.void
addResourceFile
(String path, ThrowingConsumer<Appendable> content) Add a generatedresource file
with content written to anAppendable
passed to the givenThrowingConsumer
.void
addSourceFile
(String className, CharSequence content) Add a generatedsource file
with content from the givenCharSequence
.void
addSourceFile
(String className, InputStreamSource content) Add a generatedsource file
with content from the givenInputStreamSource
.void
addSourceFile
(String className, ThrowingConsumer<Appendable> content) Add a generatedsource file
with content written to anAppendable
passed to the givenThrowingConsumer
.void
addSourceFile
(org.springframework.javapoet.JavaFile javaFile) Add a generatedsource file
with content from the givenJavaFile
.abstract void
handleFile
(GeneratedFiles.Kind kind, String path, ThrowingConsumer<GeneratedFiles.FileHandler> handler) Handle a generated file of the specifiedGeneratedFiles.Kind
with the given handler.
-
Constructor Details
-
GeneratedFiles
public GeneratedFiles()
-
-
Method Details
-
addSourceFile
public 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
public abstract 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
-