Package org.springframework.aot.generate
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
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Strategy for generating code for arguments based on their type. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.javapoet.CodeBlock
Return this method reference as aCodeBlock
.default org.springframework.javapoet.CodeBlock
toInvokeCodeBlock
(MethodReference.ArgumentCodeGenerator argumentCodeGenerator) Return this method reference as aCodeBlock
using the specifiedMethodReference.ArgumentCodeGenerator
.org.springframework.javapoet.CodeBlock
toInvokeCodeBlock
(MethodReference.ArgumentCodeGenerator argumentCodeGenerator, org.springframework.javapoet.ClassName targetClassName) Return this method reference as aCodeBlock
using the specifiedMethodReference.ArgumentCodeGenerator
.
-
Method Details
-
toCodeBlock
org.springframework.javapoet.CodeBlock toCodeBlock()Return this method reference as aCodeBlock
. If the reference is to an instance method thenthis::<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 aCodeBlock
using the specifiedMethodReference.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 aCodeBlock
using the specifiedMethodReference.ArgumentCodeGenerator
. ThetargetClassName
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 usetargetClassName
- the target class name- Returns:
- a code block to invoke the method
-