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

public final Class GeneratedClass

extends Object
Class Inheritance
Imports
java.util.Map, java.util.concurrent.ConcurrentHashMap, java.util.concurrent.atomic.AtomicInteger, java.util.function.Consumer, org.springframework.javapoet.ClassName, .JavaFile, .TypeSpec, org.springframework.lang.Nullable, org.springframework.util.Assert

A single generated class.
Authors
Phillip Webb, Stephane Nicoll
Since
6.0
See Also
GeneratedClasses

Field Summary

Modifier and TypeField and Description
private final Map<ClassName, GeneratedClass>
private final GeneratedClass
private final Map<MethodName, AtomicInteger>
private final GeneratedMethods
private final ClassName
private final Consumer<TypeSpec.Builder>

Constructor Summary

AccessConstructor and Description
pack-priv
GeneratedClass(ClassName
the generated name
name
,
Consumer<TypeSpec.Builder>
a Consumer used to build the type
type
)

Create a new GeneratedClass instance with the given name.

private

Method Summary

Modifier and TypeMethod and Description
private TypeSpec.Builder
pack-priv void
pack-priv JavaFile
private String
private TypeSpec.Builder
public GeneratedClass

Returns:

the enclosing generated class, if any
getEnclosingClass
()

Return the enclosing GeneratedClass or null if this instance represents a top-level class.

public GeneratedMethods

Returns:

the generated methods
getMethods
()

Return generated methods for this instance.

public ClassName

Returns:

the name of the generated class
getName
()

Return the name of the generated class.

public GeneratedClass

Returns:

an existing or newly generated class whose enclosing class is this class
getOrAdd
(String
the name of the nested class
name
,
Consumer<TypeSpec.Builder>
a Consumer used to build the type
type
)

Get or add a nested generated class with the specified name.

public void
reserveMethodNames(String...
the reserved method names
reservedMethodNames
)

Update this instance with a set of reserved method names that should not be used for generated methods.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

declaredClassesback to summary
private final Map<ClassName, GeneratedClass> declaredClasses
enclosingClassback to summary
private final GeneratedClass enclosingClass
Annotations
@Nullable
methodNameSequenceGeneratorback to summary
private final Map<MethodName, AtomicInteger> methodNameSequenceGenerator
methodsback to summary
private final GeneratedMethods methods
nameback to summary
private final ClassName name
typeback to summary
private final Consumer<TypeSpec.Builder> type

Constructor Detail

GeneratedClassback to summary
pack-priv GeneratedClass(ClassName name, Consumer<TypeSpec.Builder> type)

Create a new GeneratedClass instance with the given name. This constructor is package-private since names should only be generated via a GeneratedClasses.

Parameters
name:ClassName

the generated name

type:Consumer<TypeSpec.Builder>

a Consumer used to build the type

GeneratedClassback to summary
private GeneratedClass(GeneratedClass enclosingClass, ClassName name, Consumer<TypeSpec.Builder> type)

Method Detail

applyback to summary
private TypeSpec.Builder apply()
assertSameTypeback to summary
pack-priv void assertSameType(Consumer<TypeSpec.Builder> type)
generateJavaFileback to summary
pack-priv JavaFile generateJavaFile()
generateSequencedMethodNameback to summary
private String generateSequencedMethodName(MethodName name)
getBuilderback to summary
private TypeSpec.Builder getBuilder(Consumer<TypeSpec.Builder> type)
getEnclosingClassback to summary
public GeneratedClass getEnclosingClass()

Return the enclosing GeneratedClass or null if this instance represents a top-level class.

Returns:GeneratedClass

the enclosing generated class, if any

Annotations
@Nullable
getMethodsback to summary
public GeneratedMethods getMethods()

Return generated methods for this instance.

Returns:GeneratedMethods

the generated methods

getNameback to summary
public ClassName getName()

Return the name of the generated class.

Returns:ClassName

the name of the generated class

getOrAddback to summary
public GeneratedClass getOrAdd(String name, Consumer<TypeSpec.Builder> type)

Get or add a nested generated class with the specified name. If this method has previously been called with the given name, the existing class will be returned, otherwise a new class will be generated.

Parameters
name:String

the name of the nested class

type:Consumer<TypeSpec.Builder>

a Consumer used to build the type

Returns:GeneratedClass

an existing or newly generated class whose enclosing class is this class

reserveMethodNamesback to summary
public void reserveMethodNames(String... reservedMethodNames)

Update this instance with a set of reserved method names that should not be used for generated methods. Reserved names are often needed when a generated class implements a specific interface.

Parameters
reservedMethodNames:String[]

the reserved method names