Package com.google.inject.internal
Class ProviderMethod<T>
- java.lang.Object
-
- com.google.inject.internal.ProviderMethod<T>
-
- All Implemented Interfaces:
Provider<T>
,HasDependencies
,ProviderWithExtensionVisitor<T>
,ProvidesMethodBinding<T>
,javax.inject.Provider<T>
public abstract class ProviderMethod<T> extends Object implements HasDependencies, ProvidesMethodBinding<T>, ProviderWithExtensionVisitor<T>
A provider that invokes a method and returns its result.- Author:
- jessewilson@google.com (Jesse Wilson)
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <B,V>
VacceptExtensionVisitor(BindingTargetVisitor<B,V> visitor, ProviderInstanceBinding<? extends B> binding)
Instructs the extension determine if the visitor is an instance of a custom extension visitor, and if so, visit it using that method.void
configure(Binder binder)
protected T
doProvision(com.google.inject.internal.InternalContext context, Dependency<?> dependency)
Creates an object to be injected.boolean
equals(Object obj)
T
get()
Provides an instance ofT
.T
get(com.google.inject.internal.InternalContext context, Dependency<?> dependency, boolean linked)
Annotation
getAnnotation()
Returns the annotation that caused this binding to be created.Set<Dependency<?>>
getDependencies()
Returns the known dependencies for this type.Object
getEnclosingInstance()
Returns the instance of the object the method is defined in.Object
getInstance()
Key<T>
getKey()
Returns the key of the binding.Method
getMethod()
Returns the method this binding uses.int
hashCode()
String
toString()
-
-
-
Method Detail
-
getKey
public Key<T> getKey()
Description copied from interface:ProvidesMethodBinding
Returns the key of the binding.- Specified by:
getKey
in interfaceProvidesMethodBinding<T>
-
getMethod
public Method getMethod()
Description copied from interface:ProvidesMethodBinding
Returns the method this binding uses.- Specified by:
getMethod
in interfaceProvidesMethodBinding<T>
-
getInstance
public Object getInstance()
-
getEnclosingInstance
public Object getEnclosingInstance()
Description copied from interface:ProvidesMethodBinding
Returns the instance of the object the method is defined in.- Specified by:
getEnclosingInstance
in interfaceProvidesMethodBinding<T>
-
getAnnotation
public Annotation getAnnotation()
Description copied from interface:ProvidesMethodBinding
Returns the annotation that caused this binding to be created. For@Provides
methods, this is an instance of the@Provides
annotation. For bindings fromModuleAnnotatedMethodScanner
, this is the annotation that caused the scanner to produce the binding.- Specified by:
getAnnotation
in interfaceProvidesMethodBinding<T>
-
configure
public void configure(Binder binder)
-
doProvision
protected T doProvision(com.google.inject.internal.InternalContext context, Dependency<?> dependency) throws InternalProvisionException
Creates an object to be injected.- Returns:
- instance to be injected
- Throws:
InternalProvisionException
- if a value cannot be provided
-
getDependencies
public Set<Dependency<?>> getDependencies()
Description copied from interface:HasDependencies
Returns the known dependencies for this type. If this has dependencies whose values are not known statically, a dependency for theInjector
will be included in the returned set.- Specified by:
getDependencies
in interfaceHasDependencies
- Returns:
- a possibly empty set
-
acceptExtensionVisitor
public <B,V> V acceptExtensionVisitor(BindingTargetVisitor<B,V> visitor, ProviderInstanceBinding<? extends B> binding)
Description copied from interface:ProviderWithExtensionVisitor
Instructs the extension determine if the visitor is an instance of a custom extension visitor, and if so, visit it using that method. If the visitor is not an instance of the custom extension visitor, this method MUST call visitor.visit(binding).Due to issues with generics, the type parameters of this method do not relate to the type of the provider. In practice, the 'B' type will always be a supertype of 'T'.
- Specified by:
acceptExtensionVisitor
in interfaceProviderWithExtensionVisitor<T>
-
get
public final T get(com.google.inject.internal.InternalContext context, Dependency<?> dependency, boolean linked) throws InternalProvisionException
- Throws:
InternalProvisionException
-
-