org.springframework.beans.factory.config

## Class DependencyDescriptor

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

- All Implemented Interfaces:
    Serializable

      public class DependencyDescriptor
      extends Object
      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.
  Since:
    2.5
  Author:
    Juergen Hoeller
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `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(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 Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `fallbackMatchAllowed()` Return whether a fallback match is allowed.
    `DependencyDescriptor` | `forFallbackMatch()` Return a variant of this descriptor that is intended for a fallback match.
    `Annotation[]` | `getAnnotations()` Obtain the annotations associated with the wrapped parameter/field, if any.
    `Class<?>` | `getCollectionType()` Determine the generic element type of the wrapped Collection parameter/field, if any.
    `String` | `getDependencyName()` Determine the name of the wrapped parameter/field.
    `Class<?>` | `getDependencyType()` Determine the declared (non-generic) type of the wrapped parameter/field.
    `Field` | `getField()` Return the wrapped Field, if any.
    `Class<?>` | `getMapKeyType()` Determine the generic key type of the wrapped Map parameter/field, if any.
    `Class<?>` | `getMapValueType()` Determine the generic value type of the wrapped Map parameter/field, if any.
    `MethodParameter` | `getMethodParameter()` Return the wrapped MethodParameter, if any.
    `ResolvableType` | `getResolvableType()` Build a ResolvableType object for the wrapped parameter/field.
    `void` | `increaseNestingLevel()` Increase this descriptor's nesting level.
    `void` | `initParameterNameDiscovery(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.
    `void` | `setContainingClass(Class<?> containingClass)` Optionally set the concrete class that contains this dependency.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DependencyDescriptor

          public DependencyDescriptor(MethodParameter methodParameter,
                                      boolean required)

      Create 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

    - #### DependencyDescriptor

          public DependencyDescriptor(MethodParameter methodParameter,
                                      boolean required,
                                      boolean eager)

      Create 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

    - #### DependencyDescriptor

          public DependencyDescriptor(Field field,
                                      boolean required)

      Create a new descriptor for a field. Considers the dependency as 'eager'.
      Parameters:
        `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.
      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

    - #### DependencyDescriptor

          public DependencyDescriptor(DependencyDescriptor original)

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

  - ### Method Detail

    - #### getMethodParameter

          public MethodParameter getMethodParameter()

      Return the wrapped MethodParameter, if any.

      Note: Either MethodParameter or Field is available.

      Returns:
        the MethodParameter, or `null` if none

    - #### getField

          public Field getField()

      Return the wrapped Field, if any.

      Note: Either MethodParameter or Field is available.

      Returns:
        the Field, or `null` if none

    - #### isRequired

          public boolean isRequired()

      Return whether this dependency is required.

    - #### isEager

          public boolean isEager()

      Return whether this dependency is 'eager' in the sense of eagerly resolving potential target beans for type matching.

    - #### increaseNestingLevel

          public void increaseNestingLevel()

      Increase this descriptor's nesting level.
      See Also:
        `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.

    - #### getResolvableType

          public ResolvableType getResolvableType()

      Build a ResolvableType object for the wrapped parameter/field.

    - #### 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 a `AutowireCandidateResolver` that a fallback match is acceptable as well.

    - #### forFallbackMatch

          public DependencyDescriptor forFallbackMatch()

      Return a variant of this descriptor that is intended for a fallback match.
      See Also:
        `fallbackMatchAllowed()`

    - #### initParameterNameDiscovery

          public void initParameterNameDiscovery(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

          public String getDependencyName()

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

    - #### getDependencyType

          public Class<?> getDependencyType()

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

    - #### getCollectionType

          public Class<?> getCollectionType()

      Determine the generic element type of the wrapped Collection parameter/field, if any.
      Returns:
        the generic type, or `null` if none

    - #### getMapKeyType

          public Class<?> getMapKeyType()

      Determine the generic key type of the wrapped Map parameter/field, if any.
      Returns:
        the generic type, or `null` if none

    - #### getMapValueType

          public Class<?> getMapValueType()

      Determine the generic value type of the wrapped Map parameter/field, if any.
      Returns:
        the generic type, or `null` if none

    - #### getAnnotations

          public Annotation[] getAnnotations()

      Obtain the annotations associated with the wrapped parameter/field, if any.