Class DependencyDescriptor
- All Implemented Interfaces:
- Serializable
- Since:
- 2.5
- Author:
- Juergen Hoeller
- See Also:
- 
Field SummaryFields inherited from class org.springframework.beans.factory.InjectionPointfield, methodParameter
- 
Constructor SummaryConstructorsConstructorDescriptionDependencyDescriptor(Field field, boolean required) Create a new descriptor for a field.DependencyDescriptor(Field field, boolean required, boolean eager) Create a new descriptor for a field.DependencyDescriptor(DependencyDescriptor original) Copy constructor.DependencyDescriptor(MethodParameter methodParameter, boolean required) Create a new descriptor for a method or constructor parameter.DependencyDescriptor(MethodParameter methodParameter, boolean required, boolean eager) Create a new descriptor for a method or constructor parameter.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanbooleanReturn whether a fallback match is allowed.Return a variant of this descriptor that is intended for a fallback match.Determine the name of the wrapped parameter/field.Class<?>Determine the declared (non-generic) type of the wrapped parameter/field.Build aResolvableTypeobject for the wrapped parameter/field.Build aTypeDescriptorobject for the wrapped parameter/field.inthashCode()voidIncrease this descriptor's nesting level.voidinitParameterNameDiscovery(ParameterNameDiscoverer parameterNameDiscoverer) Initialize parameter name discovery for the underlying method parameter, if any.booleanisEager()Return whether this dependency is 'eager' in the sense of eagerly resolving potential target beans for type matching.booleanReturn whether this dependency is required.resolveCandidate(String beanName, Class<?> requiredType, BeanFactory beanFactory) Resolve the specified bean name, as a candidate result of the matching algorithm for this dependency, to a bean instance from the given factory.resolveNotUnique(ResolvableType type, Map<String, Object> matchingBeans) Resolve the specified not-unique scenario: by default, throwing aNoUniqueBeanDefinitionException.resolveShortcut(BeanFactory beanFactory) Resolve a shortcut for this dependency against the given factory, for example taking some pre-resolved information into account.voidsetContainingClass(Class<?> containingClass) Optionally set the concrete class that contains this dependency.booleanDetermine whether this dependency supports lazy resolution, e.g.Methods inherited from class org.springframework.beans.factory.InjectionPointgetAnnotatedElement, getAnnotation, getAnnotations, getDeclaredType, getField, getMember, getMethodParameter, obtainMethodParameter, toString
- 
Constructor Details- 
DependencyDescriptorCreate a new descriptor for a method or constructor parameter. Considers the dependency as 'eager'.- Parameters:
- methodParameter- the MethodParameter to wrap
- required- whether the dependency is required
 
- 
DependencyDescriptorCreate a new descriptor for a method or constructor parameter.- Parameters:
- methodParameter- the MethodParameter to wrap
- required- whether the dependency is required
- eager- whether this dependency is 'eager' in the sense of eagerly resolving potential target beans for type matching
 
- 
DependencyDescriptorCreate a new descriptor for a field. Considers the dependency as 'eager'.- Parameters:
- field- the field to wrap
- required- whether the dependency is required
 
- 
DependencyDescriptorCreate a new descriptor for a field.- Parameters:
- field- the field to wrap
- required- whether the dependency is required
- eager- whether this dependency is 'eager' in the sense of eagerly resolving potential target beans for type matching
 
- 
DependencyDescriptorCopy constructor.- Parameters:
- original- the original descriptor to create a copy from
 
 
- 
- 
Method Details- 
isRequiredpublic boolean isRequired()Return whether this dependency is required.Optional semantics are derived from Java 8's Optional, any variant of a parameter-levelNullableannotation (such as from JSR-305 or the FindBugs set of annotations), or a language-level nullable type declaration in Kotlin.
- 
isEagerpublic boolean isEager()Return whether this dependency is 'eager' in the sense of eagerly resolving potential target beans for type matching.
- 
resolveNotUnique@Nullable public Object resolveNotUnique(ResolvableType type, Map<String, Object> matchingBeans) throws BeansExceptionResolve the specified not-unique scenario: by default, throwing aNoUniqueBeanDefinitionException.Subclasses may override this to select one of the instances or to opt out with no result at all through returning null.- Parameters:
- type- the requested bean type
- matchingBeans- a map of bean names and corresponding bean instances which have been pre-selected for the given type (qualifiers etc already applied)
- Returns:
- a bean instance to proceed with, or nullfor none
- Throws:
- BeansException- in case of the not-unique scenario being fatal
- Since:
- 5.1
 
- 
resolveShortcutResolve a shortcut for this dependency against the given factory, for example taking some pre-resolved information into account.The resolution algorithm will first attempt to resolve a shortcut through this method before going into the regular type matching algorithm across all beans. Subclasses may override this method to improve resolution performance based on pre-cached information while still receiving InjectionPointexposure etc.- Parameters:
- beanFactory- the associated factory
- Returns:
- the shortcut result if any, or nullif none
- Throws:
- BeansException- if the shortcut could not be obtained
- Since:
- 4.3.1
 
- 
resolveCandidatepublic Object resolveCandidate(String beanName, Class<?> requiredType, BeanFactory beanFactory) throws BeansException Resolve the specified bean name, as a candidate result of the matching algorithm for this dependency, to a bean instance from the given factory.The default implementation calls BeanFactory.getBean(String). Subclasses may provide additional arguments or other customizations.- Parameters:
- beanName- the bean name, as a candidate result for this dependency
- requiredType- the expected type of the bean (as an assertion)
- beanFactory- the associated factory
- Returns:
- the bean instance (never null)
- Throws:
- BeansException- if the bean could not be obtained
- Since:
- 4.3.2
- See Also:
 
- 
increaseNestingLevelpublic void increaseNestingLevel()Increase this descriptor's nesting level.
- 
setContainingClassOptionally set the concrete class that contains this dependency. This may differ from the class that declares the parameter/field in that it may be a subclass thereof, potentially substituting type variables.- Since:
- 4.0
 
- 
getResolvableTypeBuild aResolvableTypeobject for the wrapped parameter/field.- Since:
- 4.0
 
- 
getTypeDescriptorBuild aTypeDescriptorobject for the wrapped parameter/field.- Since:
- 5.1.4
 
- 
fallbackMatchAllowedpublic boolean fallbackMatchAllowed()Return whether a fallback match is allowed.This is falseby default but may be overridden to returntruein order to suggest to anAutowireCandidateResolverthat a fallback match is acceptable as well.- Since:
- 4.0
 
- 
forFallbackMatchReturn a variant of this descriptor that is intended for a fallback match.- Since:
- 4.0
- See Also:
 
- 
initParameterNameDiscoveryInitialize parameter name discovery for the underlying method parameter, if any.This method does not actually try to retrieve the parameter name at this point; it just allows discovery to happen when the application calls getDependencyName()(if ever).
- 
getDependencyNameDetermine the name of the wrapped parameter/field.- Returns:
- the declared name (may be nullif unresolvable)
 
- 
getDependencyTypeDetermine the declared (non-generic) type of the wrapped parameter/field.- Returns:
- the declared type (never null)
 
- 
supportsLazyResolutionpublic boolean supportsLazyResolution()Determine whether this dependency supports lazy resolution, e.g. through extra proxying. The default istrue.
- 
equals- Overrides:
- equalsin class- InjectionPoint
 
- 
hashCodepublic int hashCode()- Overrides:
- hashCodein class- InjectionPoint
 
 
-