public final class

InjectionPoint

extends Object
java.lang.Object
   ↳ com.google.inject.spi.InjectionPoint

Class Overview

A constructor, field or method that can receive injections. Typically this is a member with the @Inject annotation. For non-private, no argument constructors, the member may omit the annotation.

Summary

Public Methods
boolean equals(Object o)
static <T> InjectionPoint forConstructor(Constructor<T> constructor)
Returns a new injection point for the specified constructor.
static <T> InjectionPoint forConstructor(Constructor<T> constructor, TypeLiteral<? extends T> type)
Returns a new injection point for the specified constructor of type.
static InjectionPoint forConstructorOf(TypeLiteral<?> type)
Returns a new injection point for the injectable constructor of type.
static InjectionPoint forConstructorOf(Class<?> type)
Returns a new injection point for the injectable constructor of type.
static Set<InjectionPoint> forInstanceMethodsAndFields(TypeLiteral<?> type)
Returns all instance method and field injection points on type.
static Set<InjectionPoint> forInstanceMethodsAndFields(Class<?> type)
Returns all instance method and field injection points on type.
static Set<InjectionPoint> forStaticMethodsAndFields(TypeLiteral<?> type)
Returns all static method and field injection points on type.
static Set<InjectionPoint> forStaticMethodsAndFields(Class<?> type)
Returns all static method and field injection points on type.
TypeLiteral<?> getDeclaringType()
Returns the generic type that defines this injection point.
List<Dependency<?>> getDependencies()
Returns the dependencies for this injection point.
Member getMember()
Returns the injected constructor, field, or method.
int hashCode()
boolean isOptional()
Returns true if this injection point shall be skipped if the injector cannot resolve bindings for all required dependencies.
boolean isToolable()
Returns true if the element is annotated with @Toolable.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public boolean equals (Object o)

Since: API Level

public static InjectionPoint forConstructor (Constructor<T> constructor)

Returns a new injection point for the specified constructor. If the declaring type of constructor is parameterized (such as List<T>), prefer the overload that includes a type literal.

Parameters
constructor any single constructor present on type.

public static InjectionPoint forConstructor (Constructor<T> constructor, TypeLiteral<? extends T> type)

Returns a new injection point for the specified constructor of type.

Parameters
constructor any single constructor present on type.
type the concrete type that defines constructor.

public static InjectionPoint forConstructorOf (TypeLiteral<?> type)

Returns a new injection point for the injectable constructor of type.

Parameters
type a concrete type with exactly one constructor annotated @Inject, or a no-arguments constructor that is not private.
Throws
ConfigurationException if there is no injectable constructor, more than one injectable constructor, or if parameters of the injectable constructor are malformed, such as a parameter with multiple binding annotations.

public static InjectionPoint forConstructorOf (Class<?> type)

Returns a new injection point for the injectable constructor of type.

Parameters
type a concrete type with exactly one constructor annotated @Inject, or a no-arguments constructor that is not private.
Throws
ConfigurationException if there is no injectable constructor, more than one injectable constructor, or if parameters of the injectable constructor are malformed, such as a parameter with multiple binding annotations.

public static Set<InjectionPoint> forInstanceMethodsAndFields (TypeLiteral<?> type)

Returns all instance method and field injection points on type.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
Throws
ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

public static Set<InjectionPoint> forInstanceMethodsAndFields (Class<?> type)

Returns all instance method and field injection points on type.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
Throws
ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

public static Set<InjectionPoint> forStaticMethodsAndFields (TypeLiteral<?> type)

Returns all static method and field injection points on type.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
Throws
ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

public static Set<InjectionPoint> forStaticMethodsAndFields (Class<?> type)

Returns all static method and field injection points on type.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
Throws
ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

public TypeLiteral<?> getDeclaringType ()

Returns the generic type that defines this injection point. If the member exists on a parameterized type, the result will include more type information than the member's raw declaring class.

public List<Dependency<?>> getDependencies ()

Returns the dependencies for this injection point. If the injection point is for a method or constructor, the dependencies will correspond to that member's parameters. Field injection points always have a single dependency for the field itself.

Returns
  • a possibly-empty list

public Member getMember ()

Returns the injected constructor, field, or method.

public int hashCode ()

Since: API Level

public boolean isOptional ()

Returns true if this injection point shall be skipped if the injector cannot resolve bindings for all required dependencies. Both explicit bindings (as specified in a module), and implicit bindings (@ImplementedBy, default constructors etc.) may be used to satisfy optional injection points.

public boolean isToolable ()

Returns true if the element is annotated with @Toolable.

public String toString ()

Since: API Level