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 Type
Method
Description
`default MethodReference.ArgumentCodeGenerator`
`and(Class<?> argumentType, String argumentCode)`
Create a new composed `MethodReference.ArgumentCodeGenerator` by combining this generator with supporting the given argument type.
`default MethodReference.ArgumentCodeGenerator`
`and(MethodReference.ArgumentCodeGenerator argumentCodeGenerator)`
Create a new composed `MethodReference.ArgumentCodeGenerator` by combining this generator with the given generator.
`static MethodReference.ArgumentCodeGenerator`
`from(Function<org.springframework.javapoet.TypeName,org.springframework.javapoet.CodeBlock> function)`
Factory method that creates a new `MethodReference.ArgumentCodeGenerator` from a lambda friendly function.
`org.springframework.javapoet.CodeBlock`
`generateCode(org.springframework.javapoet.TypeName argumentType)`
Generate the code for the given argument type.
`static MethodReference.ArgumentCodeGenerator`
`none()`
Factory method that returns an `MethodReference.ArgumentCodeGenerator` that always returns `null`.
`static MethodReference.ArgumentCodeGenerator`
`of(Class<?> argumentType, String argumentCode)`
Factory method that can be used to create an `MethodReference.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, return `null`.

Parameters:
  `argumentType` - the argument type
Returns:
  the code for this argument, or `null`

### none

static MethodReference.ArgumentCodeGenerator none()
Factory method that returns an `MethodReference.ArgumentCodeGenerator` that always returns `null`.

Returns:
  a new `MethodReference.ArgumentCodeGenerator` instance

### of

static MethodReference.ArgumentCodeGenerator of(Class<?> argumentType, String argumentCode)
Factory method that can be used to create an `MethodReference.ArgumentCodeGenerator` that support only the given argument type.

Parameters:
  `argumentType` - the argument type
  `argumentCode` - 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 new `MethodReference.ArgumentCodeGenerator` from a lambda friendly function. The given function is provided with the argument type and must provide the code to use or `null` if the type is not supported.

Parameters:
  `function` - the resolver function
Returns:
  a new `MethodReference.ArgumentCodeGenerator` instance backed by the function

### and

default MethodReference.ArgumentCodeGenerator and(Class<?> argumentType, String argumentCode)
Create a new composed `MethodReference.ArgumentCodeGenerator` by combining this generator with supporting the given argument type.

Parameters:
  `argumentType` - the argument type
  `argumentCode` - 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 composed `MethodReference.ArgumentCodeGenerator` by combining this generator with the given generator.

Parameters:
  `argumentCodeGenerator` - the argument generator to add
Returns:
  a new composite `MethodReference.ArgumentCodeGenerator` instance