Package org.springframework.aot.generate
Class MethodReference
java.lang.Object
org.springframework.aot.generate.MethodReference
A reference to a static or instance method.
- Since:
- 6.0
- Author:
- Phillip Webb
-
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.javapoet.ClassName
Return the referenced declaring class.Return the referenced method name.static MethodReference
Create a new method reference that refers to the given instance method.static MethodReference
Create a new method reference that refers to the given instance method.static MethodReference
Create a new method reference that refers to the given instance method.static MethodReference
Create a new method reference that refers to the given static method.static MethodReference
Create a new method reference that refers to the given static method.org.springframework.javapoet.CodeBlock
Return this method reference as aCodeBlock
.org.springframework.javapoet.CodeBlock
toCodeBlock
(String instanceVariable) Return this method reference as aCodeBlock
.org.springframework.javapoet.CodeBlock
toInvokeCodeBlock
(String instanceVariable, org.springframework.javapoet.CodeBlock... arguments) Return this method reference as an invocationCodeBlock
.org.springframework.javapoet.CodeBlock
toInvokeCodeBlock
(org.springframework.javapoet.CodeBlock... arguments) Return this method reference as an invocationCodeBlock
.toString()
-
Method Details
-
of
Create a new method reference that refers to the given instance method.- Parameters:
methodName
- the method name- Returns:
- a new
MethodReference
instance
-
of
Create a new method reference that refers to the given instance method.- Parameters:
declaringClass
- the declaring classmethodName
- the method name- Returns:
- a new
MethodReference
instance
-
of
public static MethodReference of(org.springframework.javapoet.ClassName declaringClass, String methodName) Create a new method reference that refers to the given instance method.- Parameters:
declaringClass
- the declaring classmethodName
- the method name- Returns:
- a new
MethodReference
instance
-
ofStatic
Create a new method reference that refers to the given static method.- Parameters:
declaringClass
- the declaring classmethodName
- the method name- Returns:
- a new
MethodReference
instance
-
ofStatic
public static MethodReference ofStatic(org.springframework.javapoet.ClassName declaringClass, String methodName) Create a new method reference that refers to the given static method.- Parameters:
declaringClass
- the declaring classmethodName
- the method name- Returns:
- a new
MethodReference
instance
-
getDeclaringClass
public org.springframework.javapoet.ClassName getDeclaringClass()Return the referenced declaring class.- Returns:
- the declaring class
-
getMethodName
Return the referenced method name.- Returns:
- the method name
-
toCodeBlock
public 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.
- See Also:
-
toCodeBlock
Return this method reference as aCodeBlock
. If the reference is to an instance method andinstanceVariable
isnull
thenthis::<method name>
will be returned. NoinstanceVariable
can be specified for static method references.- Parameters:
instanceVariable
- the instance variable ornull
- Returns:
- a code block for the method reference.
- See Also:
-
toInvokeCodeBlock
public org.springframework.javapoet.CodeBlock toInvokeCodeBlock(org.springframework.javapoet.CodeBlock... arguments) Return this method reference as an invocationCodeBlock
.- Parameters:
arguments
- the method arguments- Returns:
- a code back to invoke the method
-
toInvokeCodeBlock
public org.springframework.javapoet.CodeBlock toInvokeCodeBlock(@Nullable String instanceVariable, org.springframework.javapoet.CodeBlock... arguments) Return this method reference as an invocationCodeBlock
.- Parameters:
instanceVariable
- the instance variable ornull
arguments
- the method arguments- Returns:
- a code back to invoke the method
-
toString
-