Top Description Inners Fields Constructors Methods
org.springframework.beans.factory.aot

pack-priv Class BeanDefinitionPropertiesCodeGenerator

extends Object
Class Inheritance
Imports
java.beans.PropertyDescriptor, java.lang.reflect.Method, java.util.ArrayDeque, .ArrayList, .Arrays, .Collection, .Collections, .HashMap, .List, .Map, .Objects, .Set, java.util.function.BiFunction, .BiPredicate, .Function, .Predicate, org.springframework.aot.generate.GeneratedMethods, .ValueCodeGenerator, .ValueCodeGenerator.Delegate, .ValueCodeGeneratorDelegates, org.springframework.aot.hint.ExecutableMode, .MemberCategory, .RuntimeHints, .TypeReference, org.springframework.beans.BeanUtils, .MutablePropertyValues, .PropertyValue, org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.config.BeanDefinition, .ConfigurableBeanFactory, .ConstructorArgumentValues, .ConstructorArgumentValues.ValueHolder, org.springframework.beans.factory.support.AbstractBeanDefinition, .AutowireCandidateQualifier, .InstanceSupplier, .RootBeanDefinition, org.springframework.javapoet.CodeBlock, .CodeBlock.Builder, org.springframework.lang.Nullable, org.springframework.util.ClassUtils, .ObjectUtils, .ReflectionUtils, .StringUtils

Internal code generator to set RootBeanDefinition properties.

Generates code in the following form:

beanDefinition.setPrimary(true);
beanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
...

The generated code expects the following variables to be available:

Note that this generator does not set the InstanceSupplier.

Authors
Phillip Webb, Stephane Nicoll, Sam Brannen
Since
6.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final Predicate<String>
private static final String
private static final RootBeanDefinition
private final RuntimeHints
private final ValueCodeGenerator

Constructor Summary

AccessConstructor and Description
pack-priv
BeanDefinitionPropertiesCodeGenerator(RuntimeHints hints, Predicate<String> attributeFilter, GeneratedMethods generatedMethods, List<ValueCodeGenerator.Delegate> additionalDelegates, BiFunction<String, Object, CodeBlock> customValueCodeGenerator)

Method Summary

Modifier and TypeMethod and Description
private void
private void
private void
addInitDestroyHint(Class<?> beanUserClass, String methodName)

private void
addInitDestroyMethods(CodeBlock.Builder code, AbstractBeanDefinition beanDefinition, String[] methodNames, String format)

private void
private void
private <B extends BeanDefinition, T> void
addStatementForValue(CodeBlock.Builder code, BeanDefinition beanDefinition, Function<B, T> getter, String format)

private <B extends BeanDefinition, T> void
addStatementForValue(CodeBlock.Builder code, BeanDefinition beanDefinition, Function<B, T> getter, BiPredicate<T, T> filter, String format)

private <B extends BeanDefinition, T> void
addStatementForValue(CodeBlock.Builder code, BeanDefinition beanDefinition, Function<B, T> getter, BiPredicate<T, T> filter, String format, Function<T, Object> formatter)

private CodeBlock

Returns:

the existing value or a form of (castType) valueCode if a cast is necessary
castIfNecessary
(boolean
whether a cast is necessary
castNecessary
,
Class<?>
the type to cast to
castType
,
CodeBlock
the code for the value
valueCode
)

Cast the specified valueCode to the specified castType if the castNecessary is true.

pack-priv CodeBlock
private CodeBlock
private Class<?>
private Map<String, Method>
private boolean
hasDependsOn(String[] defaultValue, String[] actualValue)

private boolean
hasRole(int defaultValue, int actualValue)

private boolean
hasScope(String defaultValue, String actualValue)

private void
registerReflectionHints(RootBeanDefinition beanDefinition, Method writeMethod)

private Object
toRole(int value)

private CodeBlock
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributeFilterback to summary
private final Predicate<String> attributeFilter
BEAN_DEFINITION_VARIABLEback to summary
private static final String BEAN_DEFINITION_VARIABLE
DEFAULT_BEAN_DEFINITIONback to summary
private static final RootBeanDefinition DEFAULT_BEAN_DEFINITION
hintsback to summary
private final RuntimeHints hints
valueCodeGeneratorback to summary
private final ValueCodeGenerator valueCodeGenerator

Constructor Detail

BeanDefinitionPropertiesCodeGeneratorback to summary
pack-priv BeanDefinitionPropertiesCodeGenerator(RuntimeHints hints, Predicate<String> attributeFilter, GeneratedMethods generatedMethods, List<ValueCodeGenerator.Delegate> additionalDelegates, BiFunction<String, Object, CodeBlock> customValueCodeGenerator)

Method Detail

addAttributesback to summary
private void addAttributes(CodeBlock.Builder code, BeanDefinition beanDefinition)
addConstructorArgumentValuesback to summary
private void addConstructorArgumentValues(CodeBlock.Builder code, BeanDefinition beanDefinition)
addInitDestroyHintback to summary
private void addInitDestroyHint(Class<?> beanUserClass, String methodName)
addInitDestroyMethodsback to summary
private void addInitDestroyMethods(CodeBlock.Builder code, AbstractBeanDefinition beanDefinition, String[] methodNames, String format)
addPropertyValuesback to summary
private void addPropertyValues(CodeBlock.Builder code, RootBeanDefinition beanDefinition)
addQualifiersback to summary
private void addQualifiers(CodeBlock.Builder code, RootBeanDefinition beanDefinition)
addStatementForValueback to summary
private <B extends BeanDefinition, T> void addStatementForValue(CodeBlock.Builder code, BeanDefinition beanDefinition, Function<B, T> getter, String format)
addStatementForValueback to summary
private <B extends BeanDefinition, T> void addStatementForValue(CodeBlock.Builder code, BeanDefinition beanDefinition, Function<B, T> getter, BiPredicate<T, T> filter, String format)
addStatementForValueback to summary
private <B extends BeanDefinition, T> void addStatementForValue(CodeBlock.Builder code, BeanDefinition beanDefinition, Function<B, T> getter, BiPredicate<T, T> filter, String format, Function<T, Object> formatter)
Annotations
@SuppressWarnings:unchecked
castIfNecessaryback to summary
private CodeBlock castIfNecessary(boolean castNecessary, Class<?> castType, CodeBlock valueCode)

Cast the specified valueCode to the specified castType if the castNecessary is true. Otherwise return the valueCode as is.

Parameters
castNecessary:boolean

whether a cast is necessary

castType:Class<?>

the type to cast to

valueCode:CodeBlock

the code for the value

Returns:CodeBlock

the existing value or a form of (castType) valueCode if a cast is necessary

generateCodeback to summary
pack-priv CodeBlock generateCode(RootBeanDefinition beanDefinition)
generateValueback to summary
private CodeBlock generateValue(String name, Object value)
getInfrastructureTypeback to summary
private Class<?> getInfrastructureType(RootBeanDefinition beanDefinition)
getWriteMethodsback to summary
private Map<String, Method> getWriteMethods(Class<?> clazz)
hasDependsOnback to summary
private boolean hasDependsOn(String[] defaultValue, String[] actualValue)
hasRoleback to summary
private boolean hasRole(int defaultValue, int actualValue)
hasScopeback to summary
private boolean hasScope(String defaultValue, String actualValue)
registerReflectionHintsback to summary
private void registerReflectionHints(RootBeanDefinition beanDefinition, Method writeMethod)
toRoleback to summary
private Object toRole(int value)
toStringVarArgsback to summary
private CodeBlock toStringVarArgs(String[] strings)
org.springframework.beans.factory.aot back to summary

pack-priv Class BeanDefinitionPropertiesCodeGenerator.PropertyNamesStack

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.beans.factory.aot.BeanDefinitionPropertiesCodeGenerator.PropertyNamesStack

Field Summary

Modifier and TypeField and Description
private static final ThreadLocal<ArrayDeque<String>>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static String
peek()

pack-priv static void
pop()

pack-priv static void
push(String name)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

threadLocalback to summary
private static final ThreadLocal<ArrayDeque<String>> threadLocal

Constructor Detail

PropertyNamesStackback to summary
pack-priv PropertyNamesStack()

Method Detail

peekback to summary
pack-priv static String peek()
Annotations
@Nullable
popback to summary
pack-priv static void pop()
pushback to summary
pack-priv static void push(String name)