Top Description Fields Constructors Methods
org.springframework.aot.generate

public Class DefaultGenerationContext

extends Object
implements GenerationContext
Class Inheritance
All Implemented Interfaces
org.springframework.aot.generate.GenerationContext
Imports
java.util.Map, java.util.concurrent.ConcurrentHashMap, java.util.concurrent.atomic.AtomicInteger, org.springframework.aot.hint.RuntimeHints, org.springframework.util.Assert

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.

Authors
Phillip Webb, Stephane Nicoll, Sam Brannen
Since
6.0

Field Summary

Modifier and TypeField and Description
private final GeneratedClasses
private final GeneratedFiles
private final RuntimeHints
private final Map<String, AtomicInteger>

Constructor Summary

AccessConstructor and Description
public
DefaultGenerationContext(ClassNameGenerator
the naming convention to use for generated class names
classNameGenerator
,
GeneratedFiles
the generated files
generatedFiles
)

Create a new DefaultGenerationContext instance backed by the specified ClassNameGenerator and GeneratedFiles.

public
DefaultGenerationContext(ClassNameGenerator
the naming convention to use for generated class names
classNameGenerator
,
GeneratedFiles
the generated files
generatedFiles
,
RuntimeHints
the runtime hints
runtimeHints
)

Create a new DefaultGenerationContext instance backed by the specified ClassNameGenerator, GeneratedFiles, and RuntimeHints.

pack-priv
DefaultGenerationContext(GeneratedClasses
the generated classes
generatedClasses
,
GeneratedFiles
the generated files
generatedFiles
,
RuntimeHints
the runtime hints
runtimeHints
)

Create a new DefaultGenerationContext instance backed by the specified items.

protected
DefaultGenerationContext(DefaultGenerationContext
the existing context upon which to base the new one
existing
,
String
the feature name to use
featureName
)

Create a new DefaultGenerationContext instance based on the supplied existing context and feature name.

Method Summary

Modifier and TypeMethod and Description
public GeneratedClasses
public GeneratedFiles
public RuntimeHints
public DefaultGenerationContext
withName(String
the name to use
name
)

Implements org.springframework.aot.generate.GenerationContext.withName.

Create a new GenerationContext instance using the specified name to qualify generated assets for a dedicated round of code generation.

public void
writeGeneratedContent()

Write any generated content out to the generated files.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

generatedClassesback to summary
private final GeneratedClasses generatedClasses
generatedFilesback to summary
private final GeneratedFiles generatedFiles
runtimeHintsback to summary
private final RuntimeHints runtimeHints
sequenceGeneratorback to summary
private final Map<String, AtomicInteger> sequenceGenerator

Constructor Detail

DefaultGenerationContextback to summary
public DefaultGenerationContext(ClassNameGenerator classNameGenerator, GeneratedFiles generatedFiles)

Create a new DefaultGenerationContext instance backed by the specified ClassNameGenerator and GeneratedFiles.

Parameters
classNameGenerator:ClassNameGenerator

the naming convention to use for generated class names

generatedFiles:GeneratedFiles

the generated files

DefaultGenerationContextback to summary
public DefaultGenerationContext(ClassNameGenerator classNameGenerator, GeneratedFiles generatedFiles, RuntimeHints runtimeHints)

Create a new DefaultGenerationContext instance backed by the specified ClassNameGenerator, GeneratedFiles, and RuntimeHints.

Parameters
classNameGenerator:ClassNameGenerator

the naming convention to use for generated class names

generatedFiles:GeneratedFiles

the generated files

runtimeHints:RuntimeHints

the runtime hints

DefaultGenerationContextback to summary
pack-priv DefaultGenerationContext(GeneratedClasses generatedClasses, GeneratedFiles generatedFiles, RuntimeHints runtimeHints)

Create a new DefaultGenerationContext instance backed by the specified items.

Parameters
generatedClasses:GeneratedClasses

the generated classes

generatedFiles:GeneratedFiles

the generated files

runtimeHints:RuntimeHints

the runtime hints

DefaultGenerationContextback to summary
protected DefaultGenerationContext(DefaultGenerationContext existing, String featureName)

Create a new DefaultGenerationContext instance based on the supplied existing context and feature name.

Parameters
existing:DefaultGenerationContext

the existing context upon which to base the new one

featureName:String

the feature name to use

Since
6.0.12

Method Detail

getGeneratedClassesback to summary
public GeneratedClasses getGeneratedClasses()

Implements org.springframework.aot.generate.GenerationContext.getGeneratedClasses.

Doc from org.springframework.aot.generate.GenerationContext.getGeneratedClasses.

Get the GeneratedClasses used by the context.

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

Returns:GeneratedClasses

the generated classes

Annotations
@Override
getGeneratedFilesback to summary
public GeneratedFiles getGeneratedFiles()

Implements org.springframework.aot.generate.GenerationContext.getGeneratedFiles.

Doc from org.springframework.aot.generate.GenerationContext.getGeneratedFiles.

Get the GeneratedFiles used by the context.

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

Returns:GeneratedFiles

the generated files

Annotations
@Override
getRuntimeHintsback to summary
public RuntimeHints getRuntimeHints()

Implements org.springframework.aot.generate.GenerationContext.getRuntimeHints.

Doc from org.springframework.aot.generate.GenerationContext.getRuntimeHints.

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.

Returns:RuntimeHints

the runtime hints

Annotations
@Override
withNameback to summary
public DefaultGenerationContext withName(String name)

Implements org.springframework.aot.generate.GenerationContext.withName.

Doc from org.springframework.aot.generate.GenerationContext.withName.

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.

Parameters
name:String

the name to use

Returns:DefaultGenerationContext

a specialized GenerationContext for the specified name

Annotations
@Override
writeGeneratedContentback to summary
public void writeGeneratedContent()

Write any generated content out to the generated files.