Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2002-2009 the original author or authors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.springframework.beans.factory.config;
 
 
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.

Author(s):
Juergen Hoeller
Since:
2.5
 
 public class DependencyDescriptor implements Serializable {
 
 	private transient MethodParameter methodParameter;
 
 	private transient Field field;
 
 	private Class declaringClass;
 
 	private String methodName;
 
 	private Class[] parameterTypes;
 
 	private int parameterIndex;
 
 	private String fieldName;
 
 	private final boolean required;
 
 	private final boolean eager;
 
 	private transient Annotation[] fieldAnnotations;


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(MethodParameter methodParameterboolean required) {
 		this(methodParameterrequiredtrue);
 	}

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(MethodParameter methodParameterboolean requiredboolean eager) {
 		Assert.notNull(methodParameter"MethodParameter must not be null");
 		this. = methodParameter;
 		this. = methodParameter.getDeclaringClass();
 		if (this..getMethod() != null) {
 			this. = methodParameter.getMethod().getName();
 			this. = methodParameter.getMethod().getParameterTypes();
 		}
 		else {
 			this. = methodParameter.getConstructor().getParameterTypes();
 		}
 		this. = methodParameter.getParameterIndex();
 		this. = required;
 		this. = eager;
 	}

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(Field fieldboolean required) {
		this(fieldrequiredtrue);
	}

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
	public DependencyDescriptor(Field fieldboolean requiredboolean eager) {
		Assert.notNull(field"Field must not be null");
		this. = field;
		this. = field.getName();
		this. = required;
		this. = eager;
	}


Return the wrapped MethodParameter, if any.

Note: Either MethodParameter or Field is available.

Returns:
the MethodParameter, or null if none
		return this.;
	}

Return the wrapped Field, if any.

Note: Either MethodParameter or Field is available.

Returns:
the Field, or null if none
	public Field getField() {
		return this.;
	}

Return whether this dependency is required.
	public boolean isRequired() {
		return this.;
	}

Return whether this dependency is 'eager' in the sense of eagerly resolving potential target beans for type matching.
	public boolean isEager() {
		return this.;
	}


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

	public void initParameterNameDiscovery(ParameterNameDiscoverer parameterNameDiscoverer) {
		if (this. != null) {
			this..initParameterNameDiscovery(parameterNameDiscoverer);
		}
	}

Determine the name of the wrapped parameter/field.

Returns:
the declared name (never null)
		return (this. != null ? this..getName() : this..getParameterName());
	}

Determine the declared (non-generic) type of the wrapped parameter/field.

Returns:
the declared type (never null)
	public Class<?> getDependencyType() {
		return (this. != null ? this..getType() : this..getParameterType());
	}

Determine the generic type of the wrapped parameter/field.

Returns:
the generic type (never null)
		return (this. != null ? this..getGenericType() : this..getGenericParameterType());
	}

Determine the generic element type of the wrapped Collection parameter/field, if any.

Returns:
the generic type, or null if none
	public Class<?> getCollectionType() {
		return (this. != null ?
				GenericCollectionTypeResolver.getCollectionFieldType(this.) :
				GenericCollectionTypeResolver.getCollectionParameterType(this.));
	}

Determine the generic key type of the wrapped Map parameter/field, if any.

Returns:
the generic type, or null if none
	public Class<?> getMapKeyType() {
		return (this. != null ?
				GenericCollectionTypeResolver.getMapKeyFieldType(this.) :
				GenericCollectionTypeResolver.getMapKeyParameterType(this.));
	}

Determine the generic value type of the wrapped Map parameter/field, if any.

Returns:
the generic type, or null if none
	public Class<?> getMapValueType() {
		return (this. != null ?
				GenericCollectionTypeResolver.getMapValueFieldType(this.) :
				GenericCollectionTypeResolver.getMapValueParameterType(this.));
	}

Obtain the annotations associated with the wrapped parameter/field, if any.
	public Annotation[] getAnnotations() {
		if (this. != null) {
			if (this. == null) {
			}
			return this.;
		}
		else {
		}
	}
	//---------------------------------------------------------------------
	// Serialization support
	//---------------------------------------------------------------------
		// Rely on default serialization; just initialize state after deserialization.
		// Restore reflective handles (which are unfortunately not serializable)
		try {
			if (this. != null) {
			}
			else if (this. != null) {
			}
			else {
			}
		}
		catch (Throwable ex) {
			throw new IllegalStateException("Could not find original class structure"ex);
		}
	}
New to GrepCode? Check out our FAQ X