Class InjectionPoint
- java.lang.Object
-
- org.elasticsearch.common.inject.spi.InjectionPoint
-
public final class InjectionPoint extends java.lang.ObjectA constructor, field or method that can receive injections. Typically this is a member with the @Injectannotation. For non-private, no argument constructors, the member may omit the annotation.- Since:
- 2.0
-
-
Method Summary
Modifier and Type Method Description booleanequals(java.lang.Object o)static InjectionPointforConstructorOf(java.lang.Class<?> type)Returns a new injection point for the injectable constructor oftype.static InjectionPointforConstructorOf(TypeLiteral<?> type)Returns a new injection point for the injectable constructor oftype.static java.util.Set<InjectionPoint>forInstanceMethodsAndFields(java.lang.Class<?> type)Returns all instance method and field injection points ontype.static java.util.Set<InjectionPoint>forInstanceMethodsAndFields(TypeLiteral<?> type)Returns all instance method and field injection points ontype.static java.util.Set<InjectionPoint>forStaticMethodsAndFields(java.lang.Class<?> type)Returns all static method and field injection points ontype.static java.util.Set<InjectionPoint>forStaticMethodsAndFields(TypeLiteral type)Returns all static method and field injection points ontype.java.util.List<Dependency<?>>getDependencies()Returns the dependencies for this injection point.java.lang.reflect.MembergetMember()Returns the injected constructor, field, or method.inthashCode()booleanisOptional()Returns true if this injection point shall be skipped if the injector cannot resolve bindings for all required dependencies.java.lang.StringtoString()
-
-
-
Method Detail
-
getMember
public java.lang.reflect.Member getMember()
Returns the injected constructor, field, or method.
-
getDependencies
public java.util.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
-
isOptional
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.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
forConstructorOf
public static InjectionPoint forConstructorOf(TypeLiteral<?> type)
Returns a new injection point for the injectable constructor oftype.- 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.
-
forConstructorOf
public static InjectionPoint forConstructorOf(java.lang.Class<?> type)
Returns a new injection point for the injectable constructor oftype.- 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.
-
forStaticMethodsAndFields
public static java.util.Set<InjectionPoint> forStaticMethodsAndFields(TypeLiteral type)
Returns all static method and field injection points ontype.- 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 ontype, such as a field with multiple binding annotations. The exception'spartial valueis aSet<InjectionPoint>of the valid injection points.
-
forStaticMethodsAndFields
public static java.util.Set<InjectionPoint> forStaticMethodsAndFields(java.lang.Class<?> type)
Returns all static method and field injection points ontype.- 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 ontype, such as a field with multiple binding annotations. The exception'spartial valueis aSet<InjectionPoint>of the valid injection points.
-
forInstanceMethodsAndFields
public static java.util.Set<InjectionPoint> forInstanceMethodsAndFields(TypeLiteral<?> type)
Returns all instance method and field injection points ontype.- 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 ontype, such as a field with multiple binding annotations. The exception'spartial valueis aSet<InjectionPoint>of the valid injection points.
-
forInstanceMethodsAndFields
public static java.util.Set<InjectionPoint> forInstanceMethodsAndFields(java.lang.Class<?> type)
Returns all instance method and field injection points ontype.- 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 ontype, such as a field with multiple binding annotations. The exception'spartial valueis aSet<InjectionPoint>of the valid injection points.
-
-