org.springframework.beans.factory.config

## 类 DependencyDescriptor

- java.lang.Object
- - org.springframework.beans.factory.InjectionPoint
  - - org.springframework.beans.factory.config.DependencyDescriptor

- 所有已实现的接口:
    Serializable

      public class DependencyDescriptor
      extends InjectionPoint
      implements Serializable

  Descriptor for a specific dependency that is about to be injected. Wraps a constructor parameter, a method parameter or a field, allowing unified access to their metadata.
  从以下版本开始:
    2.5
  作者:
    Juergen Hoeller
  另请参阅:
    序列化表格

- - ### 字段概要

    - ### 从类继承的字段 org.springframework.beans.factory.InjectionPoint

      `field, methodParameter`

  - ### 构造器概要

    构造器
    构造器和说明
    `DependencyDescriptor(DependencyDescriptor original)` Copy constructor.
    `DependencyDescriptor(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(org.springframework.core.MethodParameter methodParameter, boolean required)` Create a new descriptor for a method or constructor parameter.
    `DependencyDescriptor(org.springframework.core.MethodParameter methodParameter, boolean required, boolean eager)` Create a new descriptor for a method or constructor parameter.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `boolean` | `equals(Object other)`
    `boolean` | `fallbackMatchAllowed()` Return whether a fallback match is allowed.
    `DependencyDescriptor` | `forFallbackMatch()` Return a variant of this descriptor that is intended for a fallback match.
    `String` | `getDependencyName()` Determine the name of the wrapped parameter/field.
    `Class<?>` | `getDependencyType()` Determine the declared (non-generic) type of the wrapped parameter/field.
    `org.springframework.core.ResolvableType` | `getResolvableType()` Build a ResolvableType object for the wrapped parameter/field.
    `void` | `increaseNestingLevel()` Increase this descriptor's nesting level.
    `void` | `initParameterNameDiscovery(org.springframework.core.ParameterNameDiscoverer parameterNameDiscoverer)` Initialize parameter name discovery for the underlying method parameter, if any.
    `boolean` | `isEager()` Return whether this dependency is 'eager' in the sense of eagerly resolving potential target beans for type matching.
    `boolean` | `isRequired()` Return whether this dependency is required.
    `Object` | `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.
    `Object` | `resolveNotUnique(Class<?> type, Map<String,Object> matchingBeans)` Resolve the specified not-unique scenario: by default, throwing a `NoUniqueBeanDefinitionException`.
    `Object` | `resolveShortcut(BeanFactory beanFactory)` Resolve a shortcut for this dependency against the given factory, for example taking some pre-resolved information into account.
    `void` | `setContainingClass(Class<?> containingClass)` Optionally set the concrete class that contains this dependency.

    - ### 从类继承的方法 org.springframework.beans.factory.InjectionPoint

      `getAnnotatedElement, getAnnotation, getAnnotations, getDeclaredType, getField, getMember, getMethodParameter, hashCode, obtainMethodParameter, toString`

    - ### 从类继承的方法 java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### 构造器详细资料

    - #### DependencyDescriptor

          public DependencyDescriptor(org.springframework.core.MethodParameter methodParameter,
                                      boolean required)

      Create a new descriptor for a method or constructor parameter. Considers the dependency as 'eager'.
      参数:
        `methodParameter` - the MethodParameter to wrap
        `required` - whether the dependency is required

    - #### DependencyDescriptor

          public DependencyDescriptor(org.springframework.core.MethodParameter methodParameter,
                                      boolean required,
                                      boolean eager)

      Create a new descriptor for a method or constructor parameter.
      参数:
        `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

    - #### DependencyDescriptor

          public DependencyDescriptor(Field field,
                                      boolean required)

      Create a new descriptor for a field. Considers the dependency as 'eager'.
      参数:
        `field` - the field to wrap
        `required` - whether the dependency is required

    - #### DependencyDescriptor

          public DependencyDescriptor(Field field,
                                      boolean required,
                                      boolean eager)

      Create a new descriptor for a field.
      参数:
        `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

    - #### DependencyDescriptor

          public DependencyDescriptor(DependencyDescriptor original)

      Copy constructor.
      参数:
        `original` - the original descriptor to create a copy from

  - ### 方法详细资料

    - #### isRequired

          public boolean isRequired()

      Return whether this dependency is required.

      Optional semantics are derived from Java 8's `Optional`, any variant of a parameter-level `Nullable` annotation (such as from JSR-305 or the FindBugs set of annotations), or a language-level nullable type declaration in Kotlin.

    - #### isEager

          public 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(Class<?> type,
                                                    Map<String,Object> matchingBeans)
                                             throws BeansException

      Resolve the specified not-unique scenario: by default, throwing a `NoUniqueBeanDefinitionException`.

      Subclasses may override this to select one of the instances or to opt out with no result at all through returning `null`.

      参数:
        `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)
      返回:
        a bean instance to proceed with, or `null` for none
      抛出:
        `BeansException` - in case of the not-unique scenario being fatal
      从以下版本开始:
        4.3

    - #### resolveShortcut

          @Nullable
          public Object resolveShortcut(BeanFactory beanFactory)
                                            throws BeansException

      Resolve 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 `InjectionPoint` exposure etc.

      参数:
        `beanFactory` - the associated factory
      返回:
        the shortcut result if any, or `null` if none
      抛出:
        `BeansException` - if the shortcut could not be obtained
      从以下版本开始:
        4.3.1

    - #### resolveCandidate

          public 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.

      参数:
        `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
      返回:
        the bean instance (never `null`)
      抛出:
        `BeansException` - if the bean could not be obtained
      从以下版本开始:
        4.3.2
      另请参阅:
        `BeanFactory.getBean(String)`

    - #### increaseNestingLevel

          public void increaseNestingLevel()

      Increase this descriptor's nesting level.
      另请参阅:
        `MethodParameter.increaseNestingLevel()`

    - #### setContainingClass

          public void setContainingClass(Class<?> containingClass)

      Optionally 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.
      从以下版本开始:
        4.0

    - #### getResolvableType

          public org.springframework.core.ResolvableType getResolvableType()

      Build a ResolvableType object for the wrapped parameter/field.
      从以下版本开始:
        4.0

    - #### fallbackMatchAllowed

          public boolean fallbackMatchAllowed()

      Return whether a fallback match is allowed.

      This is `false` by default but may be overridden to return `true` in order to suggest to an `AutowireCandidateResolver` that a fallback match is acceptable as well.

      从以下版本开始:
        4.0

    - #### forFallbackMatch

          public DependencyDescriptor forFallbackMatch()

      Return a variant of this descriptor that is intended for a fallback match.
      从以下版本开始:
        4.0
      另请参阅:
        `fallbackMatchAllowed()`

    - #### initParameterNameDiscovery

          public void initParameterNameDiscovery(@Nullable
                                                 org.springframework.core.ParameterNameDiscoverer parameterNameDiscoverer)

      Initialize 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).

    - #### getDependencyName

          @Nullable
          public String getDependencyName()

      Determine the name of the wrapped parameter/field.
      返回:
        the declared name (never `null`)

    - #### getDependencyType

          public Class<?> getDependencyType()

      Determine the declared (non-generic) type of the wrapped parameter/field.
      返回:
        the declared type (never `null`)

    - #### equals

          public boolean equals(Object other)

      覆盖:
        `equals` 在类中 `InjectionPoint`