Top Description Fields Constructors Methods
org.springframework.aot.generate

public Class DefaultMethodReference

extends Object
implements MethodReference
Class Inheritance
All Implemented Interfaces
org.springframework.aot.generate.MethodReference
Imports
java.util.ArrayList, .List, javax.lang.model.element.Modifier, org.springframework.javapoet.ClassName, .CodeBlock, .MethodSpec, .TypeName, org.springframework.lang.Nullable, org.springframework.util.Assert

Default MethodReference implementation based on a MethodSpec.
Authors
Stephane Nicoll, Phillip Webb
Since
6.0

Field Summary

Modifier and TypeField and Description
private final ClassName
private final MethodSpec

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
addArguments(CodeBlock.Builder
the code builder to use to add method arguments
code
,
MethodReference.ArgumentCodeGenerator
the code generator to use
argumentCodeGenerator
)

Add the code for the method arguments using the specified ArgumentCodeGenerator if necessary.

protected CodeBlock
private boolean
private boolean
public CodeBlock
public CodeBlock
toInvokeCodeBlock(MethodReference.ArgumentCodeGenerator
the argument code generator to use
argumentCodeGenerator
,
ClassName
the target class name
targetClassName
)

Implements org.springframework.aot.generate.MethodReference.toInvokeCodeBlock.

Return this method reference as a CodeBlock using the specified ArgumentCodeGenerator.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

declaringClassback to summary
private final ClassName declaringClass
Annotations
@Nullable
methodback to summary
private final MethodSpec method

Constructor Detail

DefaultMethodReferenceback to summary
public DefaultMethodReference(MethodSpec method, ClassName declaringClass)

Method Detail

addArgumentsback to summary
protected void addArguments(CodeBlock.Builder code, MethodReference.ArgumentCodeGenerator argumentCodeGenerator)

Add the code for the method arguments using the specified ArgumentCodeGenerator if necessary.

Parameters
code:CodeBlock.Builder

the code builder to use to add method arguments

argumentCodeGenerator:MethodReference.ArgumentCodeGenerator

the code generator to use

instantiateDeclaringClassback to summary
protected CodeBlock instantiateDeclaringClass(ClassName declaringClass)
isSameDeclaringClassback to summary
private boolean isSameDeclaringClass(ClassName declaringClass)
isStaticback to summary
private boolean isStatic()
toCodeBlockback to summary
public CodeBlock toCodeBlock()

Implements org.springframework.aot.generate.MethodReference.toCodeBlock.

Doc from org.springframework.aot.generate.MethodReference.toCodeBlock.

Return this method reference as a CodeBlock. If the reference is to an instance method then this::<method name> will be returned.

Returns:CodeBlock

a code block for the method reference.

Annotations
@Override
toInvokeCodeBlockback to summary
public CodeBlock toInvokeCodeBlock(MethodReference.ArgumentCodeGenerator argumentCodeGenerator, ClassName targetClassName)

Implements org.springframework.aot.generate.MethodReference.toInvokeCodeBlock.

Doc from org.springframework.aot.generate.MethodReference.toInvokeCodeBlock.

Return this method reference as a CodeBlock using the specified ArgumentCodeGenerator. The targetClassName 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:MethodReference.ArgumentCodeGenerator

the argument code generator to use

targetClassName:ClassName

the target class name

Returns:CodeBlock

a code block to invoke the method

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override