Package org.springframework.aot.generate

# Class DefaultGenerationContext

java.lang.Object
org.springframework.aot.generate.DefaultGenerationContext

All Implemented Interfaces:
  `GenerationContext`

public class DefaultGenerationContext extends Object implements GenerationContext
Default `GenerationContext` implementation.

Generated classes can be flushed out using `writeGeneratedContent()` which should be called only once after the generation process using this instance has completed.

Since:
  6.0
Author:
  Phillip Webb, Stephane Nicoll, Sam Brannen

## Constructor Summary

Constructors
Modifier
Constructor
Description
``
`DefaultGenerationContext(ClassNameGenerator classNameGenerator, GeneratedFiles generatedFiles)`
Create a new `DefaultGenerationContext` instance backed by the specified `ClassNameGenerator` and `GeneratedFiles`.
``
`DefaultGenerationContext(ClassNameGenerator classNameGenerator, GeneratedFiles generatedFiles, RuntimeHints runtimeHints)`
Create a new `DefaultGenerationContext` instance backed by the specified `ClassNameGenerator`, `GeneratedFiles`, and `RuntimeHints`.
`protected`
`DefaultGenerationContext(DefaultGenerationContext existing, String featureName)`
Create a new `DefaultGenerationContext` instance based on the supplied `existing` context and feature name.

## Method Summary

Modifier and Type
Method
Description
`GeneratedClasses`
`getGeneratedClasses()`
Get the `GeneratedClasses` used by the context.
`GeneratedFiles`
`getGeneratedFiles()`
Get the `GeneratedFiles` used by the context.
`RuntimeHints`
`getRuntimeHints()`
Get the `RuntimeHints` used by the context.
`DefaultGenerationContext`
`withName(String name)`
Create a new `GenerationContext` instance using the specified name to qualify generated assets for a dedicated round of code generation.
`void`
`writeGeneratedContent()`
Write any generated content out to the generated files.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### DefaultGenerationContext

public DefaultGenerationContext(ClassNameGenerator classNameGenerator, GeneratedFiles generatedFiles)
Create a new `DefaultGenerationContext` instance backed by the specified `ClassNameGenerator` and `GeneratedFiles`.

Parameters:
  `classNameGenerator` - the naming convention to use for generated class names
  `generatedFiles` - the generated files

### DefaultGenerationContext

public DefaultGenerationContext(ClassNameGenerator classNameGenerator, GeneratedFiles generatedFiles, RuntimeHints runtimeHints)
Create a new `DefaultGenerationContext` instance backed by the specified `ClassNameGenerator`, `GeneratedFiles`, and `RuntimeHints`.

Parameters:
  `classNameGenerator` - the naming convention to use for generated class names
  `generatedFiles` - the generated files
  `runtimeHints` - the runtime hints

### DefaultGenerationContext

protected DefaultGenerationContext(DefaultGenerationContext existing, String featureName)
Create a new `DefaultGenerationContext` instance based on the supplied `existing` context and feature name.

Parameters:
  `existing` - the existing context upon which to base the new one
  `featureName` - the feature name to use
Since:
  6.0.12

## Method Details

### getGeneratedClasses

public GeneratedClasses getGeneratedClasses()
Description copied from interface: `GenerationContext`
Get the `GeneratedClasses` used by the context.

All generated classes are written at the end of AOT processing.

Specified by:
  `getGeneratedClasses` in interface `GenerationContext`
Returns:
  the generated classes

### getGeneratedFiles

public GeneratedFiles getGeneratedFiles()
Description copied from interface: `GenerationContext`
Get the `GeneratedFiles` used by the context.

Used to write resource, java source, or class bytecode files.

Specified by:
  `getGeneratedFiles` in interface `GenerationContext`
Returns:
  the generated files

### getRuntimeHints

public RuntimeHints getRuntimeHints()
Description copied from interface: `GenerationContext`
Get the `RuntimeHints` used by the context.

Used to record reflection, resource, serialization, and proxy hints so that the application can run as a native image.

Specified by:
  `getRuntimeHints` in interface `GenerationContext`
Returns:
  the runtime hints

### withName

public DefaultGenerationContext withName(String name)
Description copied from interface: `GenerationContext`
Create a new `GenerationContext` instance using the specified name to qualify generated assets for a dedicated round of code generation.

If the specified name is already in use, a unique sequence is added to ensure the name is unique.

Specified by:
  `withName` in interface `GenerationContext`
Parameters:
  `name` - the name to use
Returns:
  a specialized `GenerationContext` for the specified name

### writeGeneratedContent

public void writeGeneratedContent()
Write any generated content out to the generated files.