Top Description Fields Constructors Methods
org.springframework.beans.factory

public Class InjectionPoint

extends Object
Class Inheritance
Known Direct Subclasses
org.springframework.beans.factory.config.DependencyDescriptor
Imports
java.lang.annotation.Annotation, java.lang.reflect.AnnotatedElement, .Field, .Member, java.util.Objects, org.springframework.core.MethodParameter, org.springframework.lang.Nullable, org.springframework.util.Assert, .ObjectUtils

A simple descriptor for an injection point, pointing to a method/constructor parameter or a field. Exposed by UnsatisfiedDependencyException. Also available as an argument for factory methods, reacting to the requesting injection point for building a customized bean instance.
Author
Juergen Hoeller
Since
4.3
See Also
UnsatisfiedDependencyException#getInjectionPoint(), org.springframework.beans.factory.config.DependencyDescriptor

Field Summary

Modifier and TypeField and Description
protected Field
private volatile Annotation[]
protected MethodParameter

Constructor Summary

AccessConstructor and Description
public
InjectionPoint(MethodParameter
the MethodParameter to wrap
methodParameter
)

Create an injection point descriptor for a method or constructor parameter.

public
InjectionPoint(Field
the field to wrap
field
)

Create an injection point descriptor for a field.

protected
InjectionPoint(InjectionPoint
the original descriptor to create a copy from
original
)

Copy constructor.

protected
InjectionPoint()

Just available for serialization purposes in subclasses.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public AnnotatedElement

Returns:

the Field / Method / Constructor as AnnotatedElement
getAnnotatedElement
()

Return the wrapped annotated element.

public <A extends Annotation> A

Returns:

the annotation instance, or null if none found
getAnnotation
(Class<A>
the annotation type to retrieve
annotationType
)

Retrieve a field/parameter annotation of the given type, if any.

public Annotation[]
getAnnotations()

Obtain the annotations associated with the wrapped field or method/constructor parameter.

public Class<?>
getDeclaredType()

Return the type declared by the underlying field or method/constructor parameter, indicating the injection type.

public Field

Returns:

the Field, or null if none
getField
()

Return the wrapped Field, if any.

public Member

Returns:

the Field / Method / Constructor as Member
getMember
()

Returns the wrapped member, containing the injection point.

public MethodParameter

Returns:

the MethodParameter, or null if none
getMethodParameter
()

Return the wrapped MethodParameter, if any.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
protected final MethodParameter

Returns:

the MethodParameter (never null)
obtainMethodParameter
()

Return the wrapped MethodParameter, assuming it is present.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

fieldback to summary
protected Field field
Annotations
@Nullable
fieldAnnotationsback to summary
private volatile Annotation[] fieldAnnotations
Annotations
@Nullable
methodParameterback to summary
protected MethodParameter methodParameter
Annotations
@Nullable

Constructor Detail

InjectionPointback to summary
public InjectionPoint(MethodParameter methodParameter)

Create an injection point descriptor for a method or constructor parameter.

Parameters
methodParameter:MethodParameter

the MethodParameter to wrap

InjectionPointback to summary
public InjectionPoint(Field field)

Create an injection point descriptor for a field.

Parameters
field:Field

the field to wrap

InjectionPointback to summary
protected InjectionPoint(InjectionPoint original)

Copy constructor.

Parameters
original:InjectionPoint

the original descriptor to create a copy from

InjectionPointback to summary
protected InjectionPoint()

Just available for serialization purposes in subclasses.

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getAnnotatedElementback to summary
public AnnotatedElement getAnnotatedElement()

Return the wrapped annotated element.

Note

In case of a method/constructor parameter, this exposes the annotations declared on the method or constructor itself (i.e. at the method/constructor level, not at the parameter level). Use getAnnotations() to obtain parameter-level annotations in such a scenario, transparently with corresponding field annotations.

Returns:AnnotatedElement

the Field / Method / Constructor as AnnotatedElement

getAnnotationback to summary
public <A extends Annotation> A getAnnotation(Class<A> annotationType)

Retrieve a field/parameter annotation of the given type, if any.

Parameters
annotationType:Class<A>

the annotation type to retrieve

Returns:A

the annotation instance, or null if none found

Annotations
@Nullable
Since
4.3.9
getAnnotationsback to summary
public Annotation[] getAnnotations()

Obtain the annotations associated with the wrapped field or method/constructor parameter.

getDeclaredTypeback to summary
public Class<?> getDeclaredType()

Return the type declared by the underlying field or method/constructor parameter, indicating the injection type.

getFieldback to summary
public Field getField()

Return the wrapped Field, if any.

Note

Either MethodParameter or Field is available.

Returns:Field

the Field, or null if none

Annotations
@Nullable
getMemberback to summary
public Member getMember()

Returns the wrapped member, containing the injection point.

Returns:Member

the Field / Method / Constructor as Member

getMethodParameterback to summary
public MethodParameter getMethodParameter()

Return the wrapped MethodParameter, if any.

Note

Either MethodParameter or Field is available.

Returns:MethodParameter

the MethodParameter, or null if none

Annotations
@Nullable
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
obtainMethodParameterback to summary
protected final MethodParameter obtainMethodParameter()

Return the wrapped MethodParameter, assuming it is present.

Returns:MethodParameter

the MethodParameter (never null)

Exceptions
IllegalStateException:
if no MethodParameter is available
Since
5.0
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override