Class GeneratedClasses

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

public class GeneratedClasses extends Object
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 Details

    • getOrAddForFeature

      public GeneratedClass getOrAddForFeature(String featureName, Consumer<org.springframework.javapoet.TypeSpec.Builder> type)
      Get or add a generated class for the specified featureName and no particular component. If this method has previously been called with the given featureName 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 class
      type - a Consumer 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 specified featureName targeting the specified component. If this method has previously been called with the given featureName/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 class
      targetComponent - the target component
      type - a Consumer 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 specified featureName and no particular component.
      Parameters:
      featureName - the name of the feature to associate with the generated class
      type - a Consumer 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 specified featureName targeting the specified component.
      Parameters:
      featureName - the name of the feature to associate with the generated class
      targetComponent - the target component
      type - a Consumer used to build the type
      Returns:
      the newly generated class