Package org.springframework.aot.generate

# Class ValueCodeGenerator

java.lang.Object
org.springframework.aot.generate.ValueCodeGenerator

public final class ValueCodeGenerator extends Object
Code generator for a single value. Delegates code generation to a list of configurable `ValueCodeGenerator.Delegate` implementations.

Since:
  6.1.2
Author:
  Stephane Nicoll

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static interface`
`ValueCodeGenerator.Delegate`
Strategy interface that can be used to implement code generation for a particular value type.

## Method Summary

Modifier and Type
Method
Description
`ValueCodeGenerator`
`add(List<ValueCodeGenerator.Delegate> additionalDelegates)`
`org.springframework.javapoet.CodeBlock`
`generateCode(Object value)`
Generate the code that represents the specified `value`.
`GeneratedMethods`
`getGeneratedMethods()`
Return the `GeneratedMethods` that represents the scope in which code generated by this instance will be added, or `null` if no specific scope is set.
`ValueCodeGenerator`
`scoped(GeneratedMethods generatedMethods)`
Return a `ValueCodeGenerator` that is scoped for the specified `GeneratedMethods`.
`static ValueCodeGenerator`
`with(List<ValueCodeGenerator.Delegate> delegates)`
Create an instance with the specified `ValueCodeGenerator.Delegate` implementations.
`static ValueCodeGenerator`
`with(ValueCodeGenerator.Delegate... delegates)`
Create an instance with the specified `ValueCodeGenerator.Delegate` implementations.
`static ValueCodeGenerator`
`withDefaults()`
Return an instance that provides support for common value types.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### withDefaults

public static ValueCodeGenerator withDefaults()
Return an instance that provides support for common value types.

Returns:
  an instance with support for common value types

### with

public static ValueCodeGenerator with(ValueCodeGenerator.Delegate... delegates)
Create an instance with the specified `ValueCodeGenerator.Delegate` implementations.

Parameters:
  `delegates` - the delegates to use
Returns:
  an instance with the specified delegates

### with

public static ValueCodeGenerator with(List<ValueCodeGenerator.Delegate> delegates)
Create an instance with the specified `ValueCodeGenerator.Delegate` implementations.

Parameters:
  `delegates` - the delegates to use
Returns:
  an instance with the specified delegates

### add

public ValueCodeGenerator add(List<ValueCodeGenerator.Delegate> additionalDelegates)

### scoped

public ValueCodeGenerator scoped(GeneratedMethods generatedMethods)
Return a `ValueCodeGenerator` that is scoped for the specified `GeneratedMethods`. This allows code generation to generate additional methods if necessary, or perform some optimization in case of visibility issues.

Parameters:
  `generatedMethods` - the generated methods to use
Returns:
  an instance scoped to the specified generated methods

### generateCode

public org.springframework.javapoet.CodeBlock generateCode(@Nullable Object value)
Generate the code that represents the specified `value`.

Parameters:
  `value` - the value to generate
Returns:
  the code that represents the specified value

### getGeneratedMethods

@Nullable public GeneratedMethods getGeneratedMethods()
Return the `GeneratedMethods` that represents the scope in which code generated by this instance will be added, or `null` if no specific scope is set.

Returns:
  the generated methods to use for code generation