Package org.springframework.aot.generate
Interface MethodReference.ArgumentCodeGenerator
- Enclosing interface:
- MethodReference
public static interface MethodReference.ArgumentCodeGenerator
Strategy for generating code for arguments based on their type.
-
Method Summary
Modifier and TypeMethodDescriptionCreate a new composedMethodReference.ArgumentCodeGenerator
by combining this generator with supporting the given argument type.and
(MethodReference.ArgumentCodeGenerator argumentCodeGenerator) Create a new composedMethodReference.ArgumentCodeGenerator
by combining this generator with the given generator.from
(Function<org.springframework.javapoet.TypeName, org.springframework.javapoet.CodeBlock> function) Factory method that creates a newMethodReference.ArgumentCodeGenerator
from a lambda friendly function.org.springframework.javapoet.CodeBlock
generateCode
(org.springframework.javapoet.TypeName argumentType) Generate the code for the given argument type.none()
Factory method that returns anMethodReference.ArgumentCodeGenerator
that always returnsnull
.Factory method that can be used to create anMethodReference.ArgumentCodeGenerator
that support only the given argument type.
-
Method Details
-
generateCode
@Nullable org.springframework.javapoet.CodeBlock generateCode(org.springframework.javapoet.TypeName argumentType) Generate the code for the given argument type. If this type is not supported, returnnull
.- Parameters:
argumentType
- the argument type- Returns:
- the code for this argument, or
null
-
none
Factory method that returns anMethodReference.ArgumentCodeGenerator
that always returnsnull
.- Returns:
- a new
MethodReference.ArgumentCodeGenerator
instance
-
of
Factory method that can be used to create anMethodReference.ArgumentCodeGenerator
that support only the given argument type.- Parameters:
argumentType
- the argument typeargumentCode
- the code for an argument of that type- Returns:
- a new
MethodReference.ArgumentCodeGenerator
instance
-
from
static MethodReference.ArgumentCodeGenerator from(Function<org.springframework.javapoet.TypeName, org.springframework.javapoet.CodeBlock> function) Factory method that creates a newMethodReference.ArgumentCodeGenerator
from a lambda friendly function. The given function is provided with the argument type and must provide the code to use ornull
if the type is not supported.- Parameters:
function
- the resolver function- Returns:
- a new
MethodReference.ArgumentCodeGenerator
instance backed by the function
-
and
Create a new composedMethodReference.ArgumentCodeGenerator
by combining this generator with supporting the given argument type.- Parameters:
argumentType
- the argument typeargumentCode
- the code for an argument of that type- Returns:
- a new composite
MethodReference.ArgumentCodeGenerator
instance
-
and
default MethodReference.ArgumentCodeGenerator and(MethodReference.ArgumentCodeGenerator argumentCodeGenerator) Create a new composedMethodReference.ArgumentCodeGenerator
by combining this generator with the given generator.- Parameters:
argumentCodeGenerator
- the argument generator to add- Returns:
- a new composite
MethodReference.ArgumentCodeGenerator
instance
-