Interface MethodReference

All Known Implementing Classes:
DefaultMethodReference

public interface MethodReference
A reference to a method with convenient code generation for referencing, or invoking it.
Since:
6.0
Author:
Stephane Nicoll, Phillip Webb
  • Method Details

    • toCodeBlock

      org.springframework.javapoet.CodeBlock toCodeBlock()
      Return this method reference as a CodeBlock. If the reference is to an instance method then this::<method name> will be returned.
      Returns:
      a code block for the method reference.
    • toInvokeCodeBlock

      default org.springframework.javapoet.CodeBlock toInvokeCodeBlock(MethodReference.ArgumentCodeGenerator argumentCodeGenerator)
      Return this method reference as a CodeBlock using the specified MethodReference.ArgumentCodeGenerator.
      Parameters:
      argumentCodeGenerator - the argument code generator to use
      Returns:
      a code block to invoke the method
    • toInvokeCodeBlock

      org.springframework.javapoet.CodeBlock toInvokeCodeBlock(MethodReference.ArgumentCodeGenerator argumentCodeGenerator, @Nullable org.springframework.javapoet.ClassName targetClassName)
      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.

      Parameters:
      argumentCodeGenerator - the argument code generator to use
      targetClassName - the target class name
      Returns:
      a code block to invoke the method