Class DefaultMethodReference

java.lang.Object
org.springframework.aot.generate.DefaultMethodReference
All Implemented Interfaces:
MethodReference

public class DefaultMethodReference extends Object implements MethodReference
Default MethodReference implementation based on a MethodSpec.
Since:
6.0
Author:
Stephane Nicoll, Phillip Webb
  • Constructor Details

    • DefaultMethodReference

      public DefaultMethodReference(org.springframework.javapoet.MethodSpec method, @Nullable org.springframework.javapoet.ClassName declaringClass)
  • Method Details

    • toCodeBlock

      public org.springframework.javapoet.CodeBlock toCodeBlock()
      Description copied from interface: MethodReference
      Return this method reference as a CodeBlock. If the reference is to an instance method then this::<method name> will be returned.
      Specified by:
      toCodeBlock in interface MethodReference
      Returns:
      a code block for the method reference.
    • toInvokeCodeBlock

      public org.springframework.javapoet.CodeBlock toInvokeCodeBlock(MethodReference.ArgumentCodeGenerator argumentCodeGenerator, @Nullable org.springframework.javapoet.ClassName targetClassName)
      Description copied from interface: MethodReference
      Return this method reference as a CodeBlock using the specified MethodReference.ArgumentCodeGenerator. The targetClassName defines the context in which the method invocation is added.

      If the caller has an instance of the type in which this method is defined, it can hint that by specifying the type as a target class.

      Specified by:
      toInvokeCodeBlock in interface MethodReference
      Parameters:
      argumentCodeGenerator - the argument code generator to use
      targetClassName - the target class name
      Returns:
      a code block to invoke the method
    • addArguments

      protected void addArguments(org.springframework.javapoet.CodeBlock.Builder code, MethodReference.ArgumentCodeGenerator argumentCodeGenerator)
      Add the code for the method arguments using the specified MethodReference.ArgumentCodeGenerator if necessary.
      Parameters:
      code - the code builder to use to add method arguments
      argumentCodeGenerator - the code generator to use
    • instantiateDeclaringClass

      protected org.springframework.javapoet.CodeBlock instantiateDeclaringClass(org.springframework.javapoet.ClassName declaringClass)
    • toString

      public String toString()
      Overrides:
      toString in class Object