Package com.google.inject.internal
Class ConstructorBindingImpl<T>
- java.lang.Object
-
- com.google.inject.internal.BindingImpl<T>
-
- com.google.inject.internal.ConstructorBindingImpl<T>
-
- All Implemented Interfaces:
Binding<T>
,DelayedInitialize
,ConstructorBinding<T>
,Element
,HasDependencies
final class ConstructorBindingImpl<T> extends BindingImpl<T> implements ConstructorBinding<T>, DelayedInitialize
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ConstructorBindingImpl.Factory<T>
-
Field Summary
Fields Modifier and Type Field Description private InjectionPoint
constructorInjectionPoint
private ConstructorBindingImpl.Factory<T>
factory
-
Constructor Summary
Constructors Modifier Constructor Description private
ConstructorBindingImpl(InjectorImpl injector, Key<T> key, java.lang.Object source, InternalFactory<? extends T> scopedFactory, Scoping scoping, ConstructorBindingImpl.Factory<T> factory, InjectionPoint constructorInjectionPoint)
ConstructorBindingImpl(Key<T> key, java.lang.Object source, Scoping scoping, InjectionPoint constructorInjectionPoint, java.util.Set<InjectionPoint> injectionPoints)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <V> V
acceptTargetVisitor(BindingTargetVisitor<? super T,V> visitor)
Accepts a target visitor.void
applyTo(Binder binder)
Writes this module element to the given binder (optional operation).(package private) static <T> ConstructorBindingImpl<T>
create(InjectorImpl injector, Key<T> key, InjectionPoint constructorInjector, java.lang.Object source, Scoping scoping, Errors errors, boolean failIfNotLinked, boolean failIfNotExplicit)
boolean
equals(java.lang.Object obj)
InjectionPoint
getConstructor()
Gets the constructor this binding injects.java.util.Set<Dependency<?>>
getDependencies()
Returns the known dependencies for this type.java.util.Set<InjectionPoint>
getInjectableMembers()
Returns all instance method and field injection points ontype
.(package private) InjectionPoint
getInternalConstructor()
Returns an injection point that can be used to clean up the constructor store.(package private) java.util.Set<Dependency<?>>
getInternalDependencies()
Returns a set of dependencies that can be iterated over to clean up stray JIT bindings.java.util.Map<java.lang.reflect.Method,java.util.List<org.aopalliance.intercept.MethodInterceptor>>
getMethodInterceptors()
Returns the interceptors applied to each method, in the order that they will be applied.private static boolean
hasAtInject(java.lang.reflect.Constructor cxtor)
Returns true if the inject annotation is on the constructor.int
hashCode()
void
initialize(InjectorImpl injector, Errors errors)
Initializes this binding, throwing any errors if necessary.(package private) boolean
isInitialized()
True if this binding has been initialized and is ready for use.java.lang.String
toString()
protected BindingImpl<T>
withKey(Key<T> key)
protected BindingImpl<T>
withScoping(Scoping scoping)
-
Methods inherited from class com.google.inject.internal.BindingImpl
acceptScopingVisitor, acceptVisitor, getInjector, getInternalFactory, getKey, getProvider, getScoping, getSource, isConstant
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.google.inject.Binding
acceptScopingVisitor, getKey, getProvider
-
Methods inherited from interface com.google.inject.spi.Element
acceptVisitor, getSource
-
-
-
-
Field Detail
-
factory
private final ConstructorBindingImpl.Factory<T> factory
-
constructorInjectionPoint
private final InjectionPoint constructorInjectionPoint
-
-
Constructor Detail
-
ConstructorBindingImpl
private ConstructorBindingImpl(InjectorImpl injector, Key<T> key, java.lang.Object source, InternalFactory<? extends T> scopedFactory, Scoping scoping, ConstructorBindingImpl.Factory<T> factory, InjectionPoint constructorInjectionPoint)
-
ConstructorBindingImpl
public ConstructorBindingImpl(Key<T> key, java.lang.Object source, Scoping scoping, InjectionPoint constructorInjectionPoint, java.util.Set<InjectionPoint> injectionPoints)
-
-
Method Detail
-
create
static <T> ConstructorBindingImpl<T> create(InjectorImpl injector, Key<T> key, InjectionPoint constructorInjector, java.lang.Object source, Scoping scoping, Errors errors, boolean failIfNotLinked, boolean failIfNotExplicit) throws ErrorsException
- Parameters:
constructorInjector
- the constructor to use, ornull
to use the default.failIfNotLinked
- true if this ConstructorBindingImpl's InternalFactory should only succeed if retrieved from a linked binding- Throws:
ErrorsException
-
hasAtInject
private static boolean hasAtInject(java.lang.reflect.Constructor cxtor)
Returns true if the inject annotation is on the constructor.
-
initialize
public void initialize(InjectorImpl injector, Errors errors) throws ErrorsException
Description copied from interface:DelayedInitialize
Initializes this binding, throwing any errors if necessary.- Specified by:
initialize
in interfaceDelayedInitialize
- Throws:
ErrorsException
-
isInitialized
boolean isInitialized()
True if this binding has been initialized and is ready for use.
-
getInternalConstructor
InjectionPoint getInternalConstructor()
Returns an injection point that can be used to clean up the constructor store.
-
getInternalDependencies
java.util.Set<Dependency<?>> getInternalDependencies()
Returns a set of dependencies that can be iterated over to clean up stray JIT bindings.
-
acceptTargetVisitor
public <V> V acceptTargetVisitor(BindingTargetVisitor<? super T,V> visitor)
Description copied from interface:Binding
Accepts a target visitor. Invokes the visitor method specific to this binding's target.- Specified by:
acceptTargetVisitor
in interfaceBinding<T>
- Parameters:
visitor
- to call back on
-
getConstructor
public InjectionPoint getConstructor()
Description copied from interface:ConstructorBinding
Gets the constructor this binding injects.- Specified by:
getConstructor
in interfaceConstructorBinding<T>
-
getInjectableMembers
public java.util.Set<InjectionPoint> getInjectableMembers()
Description copied from interface:ConstructorBinding
Returns all instance method and field injection points ontype
.- Specified by:
getInjectableMembers
in interfaceConstructorBinding<T>
- 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.
-
getMethodInterceptors
public java.util.Map<java.lang.reflect.Method,java.util.List<org.aopalliance.intercept.MethodInterceptor>> getMethodInterceptors()
Description copied from interface:ConstructorBinding
Returns the interceptors applied to each method, in the order that they will be applied.- Specified by:
getMethodInterceptors
in interfaceConstructorBinding<T>
- Returns:
- a possibly empty map
-
getDependencies
public java.util.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
-
withScoping
protected BindingImpl<T> withScoping(Scoping scoping)
- Overrides:
withScoping
in classBindingImpl<T>
-
withKey
protected BindingImpl<T> withKey(Key<T> key)
- Overrides:
withKey
in classBindingImpl<T>
-
applyTo
public void applyTo(Binder binder)
Description copied from interface:Element
Writes this module element to the given binder (optional operation).
-
toString
public java.lang.String toString()
- Overrides:
toString
in classBindingImpl<T>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-