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:
  - `InMemoryGeneratedFiles`
  - `FileSystemGeneratedFiles`

## Nested Class Summary

Nested Classes
Modifier and Type
Interface
Description
`static class`
`GeneratedFiles.FileHandler`
Provide access to a particular file and offer convenient methods to retrieve, save, or override its content.
`static enum`
`GeneratedFiles.Kind`
The various kinds of generated files that are supported.

## Method Summary

Modifier and Type
Method
Description
`default void`
`addClassFile(String path, InputStreamSource content)`
Add a generated `class file` with content from the given `InputStreamSource`.
`default void`
`addFile(GeneratedFiles.Kind kind, String path, CharSequence content)`
Add a generated file of the specified `GeneratedFiles.Kind` with content from the given `CharSequence`.
`default void`
`addFile(GeneratedFiles.Kind kind, String path, InputStreamSource content)`
Add a generated file of the specified `GeneratedFiles.Kind` with content from the given `InputStreamSource`.
`default void`
`addFile(GeneratedFiles.Kind kind, String path, ThrowingConsumer<Appendable> content)`
Add a generated file of the specified `GeneratedFiles.Kind` with content written to an `Appendable` passed to the given `ThrowingConsumer`.
`default void`
`addResourceFile(String path, CharSequence content)`
Add a generated `resource file` with content from the given `CharSequence`.
`default void`
`addResourceFile(String path, InputStreamSource content)`
Add a generated `resource file` with content from the given `InputStreamSource`.
`default void`
`addResourceFile(String path, ThrowingConsumer<Appendable> content)`
Add a generated `resource file` with content written to an `Appendable` passed to the given `ThrowingConsumer`.
`default void`
`addSourceFile(String className, CharSequence content)`
Add a generated `source file` with content from the given `CharSequence`.
`default void`
`addSourceFile(String className, InputStreamSource content)`
Add a generated `source file` with content from the given `InputStreamSource`.
`default void`
`addSourceFile(String className, ThrowingConsumer<Appendable> content)`
Add a generated `source file` with content written to an `Appendable` passed to the given `ThrowingConsumer`.
`default void`
`addSourceFile(org.springframework.javapoet.JavaFile javaFile)`
Add a generated `source file` with content from the given `JavaFile`.
`void`
`handleFile(GeneratedFiles.Kind kind, String path, ThrowingConsumer<GeneratedFiles.FileHandler> handler)`
Handle a generated file of the specified `GeneratedFiles.Kind` with the given handler.

## Method Details

### addSourceFile

default void addSourceFile(org.springframework.javapoet.JavaFile javaFile)
Add a generated `source file` with content from the given `JavaFile`.

Parameters:
  `javaFile` - the java file to add

### addSourceFile

default void addSourceFile(String className, CharSequence content)
Add a generated `source file` with content from the given `CharSequence`.

Parameters:
  `className` - the class name that should be used to determine the path of the file
  `content` - the contents of the file

### addSourceFile

default void addSourceFile(String className, ThrowingConsumer<Appendable> content)
Add a generated `source file` with content written to an `Appendable` passed to the given `ThrowingConsumer`.

Parameters:
  `className` - the class name that should be used to determine the path of the file
  `content` - a `ThrowingConsumer` that accepts an `Appendable` which will receive the file contents

### addSourceFile

default void addSourceFile(String className, InputStreamSource content)
Add a generated `source file` with content from the given `InputStreamSource`.

Parameters:
  `className` - the class name that should be used to determine the path of the file
  `content` - an `InputStreamSource` that will provide an input stream containing the file contents

### addResourceFile

default void addResourceFile(String path, CharSequence content)
Add a generated `resource file` with content from the given `CharSequence`.

Parameters:
  `path` - the relative path of the file
  `content` - the contents of the file

### addResourceFile

default void addResourceFile(String path, ThrowingConsumer<Appendable> content)
Add a generated `resource file` with content written to an `Appendable` passed to the given `ThrowingConsumer`.

Parameters:
  `path` - the relative path of the file
  `content` - a `ThrowingConsumer` that accepts an `Appendable` which will receive the file contents

### addResourceFile

default void addResourceFile(String path, InputStreamSource content)
Add a generated `resource file` with content from the given `InputStreamSource`.

Parameters:
  `path` - the relative path of the file
  `content` - an `InputStreamSource` that will provide an input stream containing the file contents

### addClassFile

default void addClassFile(String path, InputStreamSource content)
Add a generated `class file` with content from the given `InputStreamSource`.

Parameters:
  `path` - the relative path of the file
  `content` - an `InputStreamSource` that will provide an input stream containing the file contents

### addFile

default void addFile(GeneratedFiles.Kind kind, String path, CharSequence content)
Add a generated file of the specified `GeneratedFiles.Kind` with content from the given `CharSequence`.

Parameters:
  `kind` - the kind of file being written
  `path` - the relative path of the file
  `content` - the contents of the file

### addFile

default void addFile(GeneratedFiles.Kind kind, String path, ThrowingConsumer<Appendable> content)
Add a generated file of the specified `GeneratedFiles.Kind` with content written to an `Appendable` passed to the given `ThrowingConsumer`.

Parameters:
  `kind` - the kind of file being written
  `path` - the relative path of the file
  `content` - a `ThrowingConsumer` that accepts an `Appendable` which will receive the file contents

### addFile

default void addFile(GeneratedFiles.Kind kind, String path, InputStreamSource content)
Add a generated file of the specified `GeneratedFiles.Kind` with content from the given `InputStreamSource`.

Parameters:
  `kind` - the kind of file being written
  `path` - the relative path of the file
  `content` - an `InputStreamSource` 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 specified `GeneratedFiles.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 file
  `path` - the relative path of the file
  `handler` - a consumer of a `GeneratedFiles.FileHandler` for the file
Since:
  6.2