Package org.springframework.aot.generate
Class GeneratedClasses
java.lang.Object
org.springframework.aot.generate.GeneratedClasses
A managed collection of generated classes.
This class is stateful, so the same instance should be used for all class generation.
- Since:
- 6.0
- Author:
- Phillip Webb, Stephane Nicoll
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionaddForFeature
(String featureName, Consumer<org.springframework.javapoet.TypeSpec.Builder> type) Add a new generated class for the specifiedfeatureName
and no particular component.addForFeatureComponent
(String featureName, Class<?> targetComponent, Consumer<org.springframework.javapoet.TypeSpec.Builder> type) Add a new generated class for the specifiedfeatureName
targeting the specifiedcomponent
.getOrAddForFeature
(String featureName, Consumer<org.springframework.javapoet.TypeSpec.Builder> type) Get or add a generated class for the specifiedfeatureName
and no particular component.getOrAddForFeatureComponent
(String featureName, Class<?> targetComponent, Consumer<org.springframework.javapoet.TypeSpec.Builder> type) Get or add a generated class for the specifiedfeatureName
targeting the specifiedcomponent
.
-
Method Details
-
getOrAddForFeature
public GeneratedClass getOrAddForFeature(String featureName, Consumer<org.springframework.javapoet.TypeSpec.Builder> type) Get or add a generated class for the specifiedfeatureName
and no particular component. If this method has previously been called with the givenfeatureName
the existing class will be returned, otherwise a new class will be generated.- Parameters:
featureName
- the name of the feature to associate with the generated classtype
- aConsumer
used to build the type- Returns:
- an existing or newly generated class
-
getOrAddForFeatureComponent
public GeneratedClass getOrAddForFeatureComponent(String featureName, Class<?> targetComponent, Consumer<org.springframework.javapoet.TypeSpec.Builder> type) Get or add a generated class for the specifiedfeatureName
targeting the specifiedcomponent
. If this method has previously been called with the givenfeatureName
/target
the existing class will be returned, otherwise a new class will be generated, otherwise a new class will be generated.- Parameters:
featureName
- the name of the feature to associate with the generated classtargetComponent
- the target componenttype
- aConsumer
used to build the type- Returns:
- an existing or newly generated class
-
addForFeature
public GeneratedClass addForFeature(String featureName, Consumer<org.springframework.javapoet.TypeSpec.Builder> type) Add a new generated class for the specifiedfeatureName
and no particular component.- Parameters:
featureName
- the name of the feature to associate with the generated classtype
- aConsumer
used to build the type- Returns:
- the newly generated class
-
addForFeatureComponent
public GeneratedClass addForFeatureComponent(String featureName, Class<?> targetComponent, Consumer<org.springframework.javapoet.TypeSpec.Builder> type) Add a new generated class for the specifiedfeatureName
targeting the specifiedcomponent
.- Parameters:
featureName
- the name of the feature to associate with the generated classtargetComponent
- the target componenttype
- aConsumer
used to build the type- Returns:
- the newly generated class
-