Package org.springframework.aot.generate
Class ValueCodeGenerator
java.lang.Object
org.springframework.aot.generate.ValueCodeGenerator
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
Modifier and TypeClassDescriptionstatic interface
Strategy interface that can be used to implement code generation for a particular value type. -
Method Summary
Modifier and TypeMethodDescriptionadd
(List<ValueCodeGenerator.Delegate> additionalDelegates) org.springframework.javapoet.CodeBlock
generateCode
(Object value) Generate the code that represents the specifiedvalue
.Return theGeneratedMethods
that represents the scope in which code generated by this instance will be added, ornull
if no specific scope is set.scoped
(GeneratedMethods generatedMethods) Return aValueCodeGenerator
that is scoped for the specifiedGeneratedMethods
.static ValueCodeGenerator
with
(List<ValueCodeGenerator.Delegate> delegates) Create an instance with the specifiedValueCodeGenerator.Delegate
implementations.static ValueCodeGenerator
with
(ValueCodeGenerator.Delegate... delegates) Create an instance with the specifiedValueCodeGenerator.Delegate
implementations.static ValueCodeGenerator
Return an instance that provides support for common value types.
-
Method Details
-
withDefaults
Return an instance that provides support for common value types.- Returns:
- an instance with support for common value types
-
with
Create an instance with the specifiedValueCodeGenerator.Delegate
implementations.- Parameters:
delegates
- the delegates to use- Returns:
- an instance with the specified delegates
-
with
Create an instance with the specifiedValueCodeGenerator.Delegate
implementations.- Parameters:
delegates
- the delegates to use- Returns:
- an instance with the specified delegates
-
add
-
scoped
Return aValueCodeGenerator
that is scoped for the specifiedGeneratedMethods
. 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
Generate the code that represents the specifiedvalue
.- Parameters:
value
- the value to generate- Returns:
- the code that represents the specified value
-
getGeneratedMethods
Return theGeneratedMethods
that represents the scope in which code generated by this instance will be added, ornull
if no specific scope is set.- Returns:
- the generated methods to use for code generation
-