Class GeneratedMethods

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

public class GeneratedMethods extends Object
A managed collection of generated methods.
Since:
6.0
Author:
Phillip Webb, Stephane Nicoll
See Also:
  • Method Details

    • add

      public GeneratedMethod add(String suggestedName, Consumer<org.springframework.javapoet.MethodSpec.Builder> method)
      Add a new GeneratedMethod.

      The suggestedName should provide the unqualified form of what the method does. For instance, if the method returns an instance of a given type, getInstance can be used as it is automatically qualified using the current prefix.

      The prefix is applied a little differently for suggested names that start with get, set, or is. Taking the previous example with a myBean prefix, the actual method name is getMyBeanInstance. Further processing of the method can happen to ensure uniqueness within a class.

      Parameters:
      suggestedName - the suggested name for the method
      method - a Consumer used to build method
      Returns:
      the newly added GeneratedMethod
    • add

      public GeneratedMethod add(String[] suggestedNameParts, Consumer<org.springframework.javapoet.MethodSpec.Builder> method)
      Add a new GeneratedMethod.

      The suggestedNameParts should provide the unqualified form of what the method does. For instance, if the method returns an instance of a given type, ["get", "instance"] can be used as it is automatically qualified using the current prefix.

      The prefix is applied a little differently for suggested name parts that start with get, set, or is. Taking the previous example with a myBean prefix, the actual method name is getMyBeanInstance. Further processing of the method can happen to ensure uniqueness within a class.

      Parameters:
      suggestedNameParts - the suggested name parts for the method
      method - a Consumer used to build method
      Returns:
      the newly added GeneratedMethod
    • withPrefix

      public GeneratedMethods withPrefix(String prefix)
      Specify the prefix to use for method names. The prefix applies to suggested method names, with special handling of get, set, and is prefixes in the suggested name itself.
      Parameters:
      prefix - the prefix to add to suggested method names
      Returns:
      a new instance with the specified prefix