Package org.springframework.aot.generate
Class DefaultMethodReference
java.lang.Object
org.springframework.aot.generate.DefaultMethodReference
- All Implemented Interfaces:
MethodReference
Default
MethodReference
implementation based on a MethodSpec
.- Since:
- 6.0
- Author:
- Stephane Nicoll, Phillip Webb
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.aot.generate.MethodReference
MethodReference.ArgumentCodeGenerator
-
Constructor Summary
ConstructorDescriptionDefaultMethodReference
(org.springframework.javapoet.MethodSpec method, org.springframework.javapoet.ClassName declaringClass) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addArguments
(org.springframework.javapoet.CodeBlock.Builder code, MethodReference.ArgumentCodeGenerator argumentCodeGenerator) Add the code for the method arguments using the specifiedMethodReference.ArgumentCodeGenerator
if necessary.protected org.springframework.javapoet.CodeBlock
instantiateDeclaringClass
(org.springframework.javapoet.ClassName declaringClass) org.springframework.javapoet.CodeBlock
Return this method reference as aCodeBlock
.org.springframework.javapoet.CodeBlock
toInvokeCodeBlock
(MethodReference.ArgumentCodeGenerator argumentCodeGenerator, org.springframework.javapoet.ClassName targetClassName) Return this method reference as aCodeBlock
using the specifiedMethodReference.ArgumentCodeGenerator
.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.aot.generate.MethodReference
toInvokeCodeBlock
-
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 aCodeBlock
. If the reference is to an instance method thenthis::<method name>
will be returned.- Specified by:
toCodeBlock
in interfaceMethodReference
- 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 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.
- Specified by:
toInvokeCodeBlock
in interfaceMethodReference
- Parameters:
argumentCodeGenerator
- the argument code generator to usetargetClassName
- 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 specifiedMethodReference.ArgumentCodeGenerator
if necessary.- Parameters:
code
- the code builder to use to add method argumentsargumentCodeGenerator
- the code generator to use
-
instantiateDeclaringClass
protected org.springframework.javapoet.CodeBlock instantiateDeclaringClass(org.springframework.javapoet.ClassName declaringClass) -
toString
-