Class OverrideMetadata
java.lang.Object
org.springframework.test.context.bean.override.OverrideMetadata
Metadata for Bean Override injection points, also responsible for creation of
 the overriding instance.
 
WARNING: implementations are used as a cache key and
 must implement proper equals() and hashCode() methods.
 
Specific implementations of metadata can have state to be used during override instance creation — for example, based on further parsing of the annotation or the annotated field.
- Since:
- 6.2
- Author:
- Simon Baslé
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedOverrideMetadata(Field field, ResolvableType beanType, BeanOverrideStrategy strategy) 
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract ObjectcreateOverride(String beanName, BeanDefinition existingBeanDefinition, Object existingBeanInstance) Create an override instance from thisOverrideMetadata, optionally provided with an existingBeanDefinitionand/or an original instance, that is a singleton or an early wrapped instance.booleanprotected StringGet the bean name to override, ornullto look for a single matching bean of typegetBeanType().final ResolvableTypeGet the bean type to override.final FieldgetField()Get the annotatedField.final BeanOverrideStrategyGet theBeanOverrideStrategyfor this instance, as a hint on how and when the override instance should be created.inthashCode()toString()protected voidtrack(Object override, SingletonBeanRegistry trackingBeanRegistry) Optionally track objects created by thisOverrideMetadata.
- 
Constructor Details- 
OverrideMetadata
 
- 
- 
Method Details- 
getBeanNameGet the bean name to override, ornullto look for a single matching bean of typegetBeanType().Defaults to null.
- 
getBeanTypeGet the bean type to override.
- 
getFieldGet the annotatedField.
- 
getStrategyGet theBeanOverrideStrategyfor this instance, as a hint on how and when the override instance should be created.
- 
createOverrideprotected abstract Object createOverride(String beanName, @Nullable BeanDefinition existingBeanDefinition, @Nullable Object existingBeanInstance) Create an override instance from thisOverrideMetadata, optionally provided with an existingBeanDefinitionand/or an original instance, that is a singleton or an early wrapped instance.- Parameters:
- beanName- the name of the bean being overridden
- existingBeanDefinition- an existing bean definition for the supplied bean name, or- nullif not relevant
- existingBeanInstance- an existing instance for the supplied bean name for wrapping purposes, or- nullif irrelevant
- Returns:
- the instance with which to override the bean
 
- 
trackOptionally track objects created by thisOverrideMetadata.The default is not to track, but this can be overridden in subclasses. - Parameters:
- override- the bean override instance to track
- trackingBeanRegistry- the registry in which trackers can optionally be registered
 
- 
equals
- 
hashCodepublic int hashCode()
- 
toString
 
-