Package com.google.inject.internal
Class Scoping
java.lang.Object
com.google.inject.internal.Scoping
References a scope, either directly (as a scope instance), or indirectly (as a scope annotation).
The scope's eager or laziness is also exposed.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract <V> V
acceptVisitor
(BindingScopingVisitor<V> visitor) abstract void
applyTo
(ScopedBindingBuilder scopedBindingBuilder) boolean
static Scoping
forAnnotation
(Class<? extends Annotation> scopingAnnotation) static Scoping
forInstance
(Scope scope) Class
<? extends Annotation> Returns the scope annotation, ornull
if that isn't known for this instance.Returns the scope instance, ornull
if that isn't known for this instance.int
hashCode()
boolean
isEagerSingleton
(Stage stage) Returns true if this scope is a singleton that should be loaded eagerly instage
.boolean
Returns true if this scope was explicitly applied.boolean
Returns true if this is the default scope.(package private) static Scoping
makeInjectable
(Scoping scoping, InjectorImpl injector, Errors errors) Replaces annotation scopes with instance scopes using the Injector's annotation-to-instance map.(package private) static <T> InternalFactory
<? extends T> scope
(Key<T> key, InjectorImpl injector, InternalFactory<? extends T> creator, Object source, Scoping scoping) Scopes an internal factory.
-
Field Details
-
UNSCOPED
No scoping annotation has been applied. Note that this is different fromin(Scopes.NO_SCOPE)
, where the 'NO_SCOPE' has been explicitly applied. -
EXPLICITLY_UNSCOPED
No scoping annotation has been applied explicitly. Note that this is is the same asin(Scopes.NO_SCOPE)
. -
SINGLETON_ANNOTATION
-
SINGLETON_INSTANCE
-
EAGER_SINGLETON
-
-
Constructor Details
-
Scoping
private Scoping()
-
-
Method Details
-
forAnnotation
-
forInstance
-
isExplicitlyScoped
public boolean isExplicitlyScoped()Returns true if this scope was explicitly applied. If no scope was explicitly applied then the scoping annotation will be used. -
isNoScope
public boolean isNoScope()Returns true if this is the default scope. In this case a new instance will be provided for each injection. -
isEagerSingleton
Returns true if this scope is a singleton that should be loaded eagerly instage
. -
getScopeInstance
Returns the scope instance, ornull
if that isn't known for this instance. -
getScopeAnnotation
Returns the scope annotation, ornull
if that isn't known for this instance. -
equals
-
hashCode
public int hashCode() -
acceptVisitor
-
applyTo
-
scope
static <T> InternalFactory<? extends T> scope(Key<T> key, InjectorImpl injector, InternalFactory<? extends T> creator, Object source, Scoping scoping) Scopes an internal factory. -
makeInjectable
Replaces annotation scopes with instance scopes using the Injector's annotation-to-instance map. If the scope annotation has no corresponding instance, an error will be added and unscoped will be retuned.
-