org.springframework.beans.factory.config
Class DependencyDescriptor

java.lang.Object
  extended by org.springframework.beans.factory.config.DependencyDescriptor
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AbstractAutowireCapableBeanFactory.AutowireByTypeDependencyDescriptor, CommonAnnotationBeanPostProcessor.LookupDependencyDescriptor

public class DependencyDescriptor
extends java.lang.Object
implements java.io.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

Field Summary
private  java.lang.Class declaringClass
           
private  boolean eager
           
private  java.lang.reflect.Field field
           
private  java.lang.annotation.Annotation[] fieldAnnotations
           
private  java.lang.String fieldName
           
private  java.lang.String methodName
           
private  MethodParameter methodParameter
           
private  int parameterIndex
           
private  java.lang.Class[] parameterTypes
           
private  boolean required
           
 
Constructor Summary
DependencyDescriptor(java.lang.reflect.Field field, boolean required)
          Create a new descriptor for a field.
DependencyDescriptor(java.lang.reflect.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
 java.lang.annotation.Annotation[] getAnnotations()
          Obtain the annotations associated with the wrapped parameter/field, if any.
 java.lang.Class<?> getCollectionType()
          Determine the generic element type of the wrapped Collection parameter/field, if any.
 java.lang.String getDependencyName()
          Determine the name of the wrapped parameter/field.
 java.lang.Class<?> getDependencyType()
          Determine the declared (non-generic) type of the wrapped parameter/field.
 java.lang.reflect.Field getField()
          Return the wrapped Field, if any.
 java.lang.reflect.Type getGenericDependencyType()
          Determine the generic type of the wrapped parameter/field.
 java.lang.Class<?> getMapKeyType()
          Determine the generic key type of the wrapped Map parameter/field, if any.
 java.lang.Class<?> getMapValueType()
          Determine the generic value type of the wrapped Map parameter/field, if any.
 MethodParameter getMethodParameter()
          Return the wrapped MethodParameter, if any.
 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.
private  void readObject(java.io.ObjectInputStream ois)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

methodParameter

private transient MethodParameter methodParameter

field

private transient java.lang.reflect.Field field

declaringClass

private java.lang.Class declaringClass

methodName

private java.lang.String methodName

parameterTypes

private java.lang.Class[] parameterTypes

parameterIndex

private int parameterIndex

fieldName

private java.lang.String fieldName

required

private final boolean required

eager

private final boolean eager

fieldAnnotations

private transient java.lang.annotation.Annotation[] fieldAnnotations
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(java.lang.reflect.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(java.lang.reflect.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
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 java.lang.reflect.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.


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 java.lang.String getDependencyName()
Determine the name of the wrapped parameter/field.

Returns:
the declared name (never null)

getDependencyType

public java.lang.Class<?> getDependencyType()
Determine the declared (non-generic) type of the wrapped parameter/field.

Returns:
the declared type (never null)

getGenericDependencyType

public java.lang.reflect.Type getGenericDependencyType()
Determine the generic type of the wrapped parameter/field.

Returns:
the generic type (never null)

getCollectionType

public java.lang.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 java.lang.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 java.lang.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 java.lang.annotation.Annotation[] getAnnotations()
Obtain the annotations associated with the wrapped parameter/field, if any.


readObject

private void readObject(java.io.ObjectInputStream ois)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException