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
Nested ClassesModifier and TypeClassDescriptionstatic interfaceStrategy 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.CodeBlockgenerateCode(Object value) Generate the code that represents the specifiedvalue.Return theGeneratedMethodsthat represents the scope in which code generated by this instance will be added, ornullif no specific scope is set.scoped(GeneratedMethods generatedMethods) Return aValueCodeGeneratorthat is scoped for the specifiedGeneratedMethods.static ValueCodeGeneratorwith(List<ValueCodeGenerator.Delegate> delegates) Create an instance with the specifiedValueCodeGenerator.Delegateimplementations.static ValueCodeGeneratorwith(ValueCodeGenerator.Delegate... delegates) Create an instance with the specifiedValueCodeGenerator.Delegateimplementations.static ValueCodeGeneratorReturn 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.Delegateimplementations.- Parameters:
delegates- the delegates to use- Returns:
- an instance with the specified delegates
-
with
Create an instance with the specifiedValueCodeGenerator.Delegateimplementations.- Parameters:
delegates- the delegates to use- Returns:
- an instance with the specified delegates
-
add
-
scoped
Return aValueCodeGeneratorthat 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 theGeneratedMethodsthat represents the scope in which code generated by this instance will be added, ornullif no specific scope is set.- Returns:
- the generated methods to use for code generation
-