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
ConstructorsConstructorDescriptionDefaultMethodReference(org.springframework.javapoet.MethodSpec method, org.springframework.javapoet.ClassName declaringClass) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddArguments(org.springframework.javapoet.CodeBlock.Builder code, MethodReference.ArgumentCodeGenerator argumentCodeGenerator) Add the code for the method arguments using the specifiedMethodReference.ArgumentCodeGeneratorif necessary.protected org.springframework.javapoet.CodeBlockinstantiateDeclaringClass(org.springframework.javapoet.ClassName declaringClass) org.springframework.javapoet.CodeBlockReturn this method reference as aCodeBlock.org.springframework.javapoet.CodeBlocktoInvokeCodeBlock(MethodReference.ArgumentCodeGenerator argumentCodeGenerator, org.springframework.javapoet.ClassName targetClassName) Return this method reference as aCodeBlockusing the specifiedMethodReference.ArgumentCodeGenerator.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:MethodReferenceReturn this method reference as aCodeBlock. If the reference is to an instance method thenthis::<method name>will be returned.- Specified by:
toCodeBlockin 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:MethodReferenceReturn this method reference as aCodeBlockusing the specifiedMethodReference.ArgumentCodeGenerator. ThetargetClassNamedefines 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:
toInvokeCodeBlockin 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.ArgumentCodeGeneratorif 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
-