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.ClassNameReturn the referenced declaring class.Return the referenced method name.static MethodReferenceCreate a new method reference that refers to the given instance method.static MethodReferenceCreate a new method reference that refers to the given instance method.static MethodReferenceCreate a new method reference that refers to the given instance method.static MethodReferenceCreate a new method reference that refers to the given static method.static MethodReferenceCreate a new method reference that refers to the given static method.org.springframework.javapoet.CodeBlockReturn this method reference as aCodeBlock.org.springframework.javapoet.CodeBlocktoCodeBlock(String instanceVariable) Return this method reference as aCodeBlock.org.springframework.javapoet.CodeBlocktoInvokeCodeBlock(String instanceVariable, org.springframework.javapoet.CodeBlock... arguments) Return this method reference as an invocationCodeBlock.org.springframework.javapoet.CodeBlocktoInvokeCodeBlock(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
MethodReferenceinstance
-
of
Create a new method reference that refers to the given instance method.- Parameters:
declaringClass- the declaring classmethodName- the method name- Returns:
- a new
MethodReferenceinstance
-
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
MethodReferenceinstance
-
ofStatic
Create a new method reference that refers to the given static method.- Parameters:
declaringClass- the declaring classmethodName- the method name- Returns:
- a new
MethodReferenceinstance
-
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
MethodReferenceinstance
-
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 andinstanceVariableisnullthenthis::<method name>will be returned. NoinstanceVariablecan 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 ornullarguments- the method arguments- Returns:
- a code back to invoke the method
-
toString
-