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.
| Constructor: |
public DependencyDescriptor(MethodParameter methodParameter,
boolean required) {
this(methodParameter, required, true);
}
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
|
public DependencyDescriptor(Field field,
boolean required) {
this(field, required, true);
}
Create a new descriptor for a field.
Considers the dependency as 'eager'. Parameters:
field - the field to wrap
required - whether the dependency is required
|
public DependencyDescriptor(MethodParameter methodParameter,
boolean required,
boolean eager) {
Assert.notNull(methodParameter, "MethodParameter must not be null");
this.methodParameter = methodParameter;
this.required = required;
this.eager = 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
|
public DependencyDescriptor(Field field,
boolean required,
boolean eager) {
Assert.notNull(field, "Field must not be null");
this.field = field;
this.required = required;
this.eager = 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 from org.springframework.beans.factory.config.DependencyDescriptor Detail: |
public Object[] getAnnotations() {
if (this.field != null) {
if (this.fieldAnnotations != null) {
return this.fieldAnnotations;
}
if (fieldAnnotationsMethod == null) {
return null;
}
this.fieldAnnotations = (Object[]) ReflectionUtils.invokeMethod(fieldAnnotationsMethod, this.field);
return this.fieldAnnotations;
}
else {
return this.methodParameter.getParameterAnnotations();
}
}
Obtain the annotations associated with the wrapped parameter/field, if any. |
public Class getCollectionType() {
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_15) {
return null;
}
return (this.field != null ?
GenericCollectionTypeResolver.getCollectionFieldType(this.field) :
GenericCollectionTypeResolver.getCollectionParameterType(this.methodParameter));
}
Determine the generic element type of the wrapped Collection parameter/field, if any. |
public Class getDependencyType() {
return (this.field != null ? this.field.getType() : this.methodParameter.getParameterType());
}
Determine the declared (non-generic) type of the wrapped parameter/field. |
public Field getField() {
return this.field;
}
|
public Class getMapKeyType() {
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_15) {
return null;
}
return (this.field != null ?
GenericCollectionTypeResolver.getMapKeyFieldType(this.field) :
GenericCollectionTypeResolver.getMapKeyParameterType(this.methodParameter));
}
Determine the generic key type of the wrapped Map parameter/field, if any. |
public Class getMapValueType() {
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_15) {
return null;
}
return (this.field != null ?
GenericCollectionTypeResolver.getMapValueFieldType(this.field) :
GenericCollectionTypeResolver.getMapValueParameterType(this.methodParameter));
}
Determine the generic value type of the wrapped Map parameter/field, if any. |
public MethodParameter getMethodParameter() {
return this.methodParameter;
}
|
public boolean isEager() {
return this.eager;
}
Return whether this dependency is 'eager' in the sense of
eagerly resolving potential target beans for type matching. |
public boolean isRequired() {
return this.required;
}
Return whether this dependency is required. |