Package com.google.inject.internal
Class Scoping
- java.lang.Object
-
- com.google.inject.internal.Scoping
-
public abstract class Scoping extends java.lang.ObjectReferences 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 Modifier and Type Field Description static ScopingEAGER_SINGLETONprivate static ScopingEXPLICITLY_UNSCOPEDNo scoping annotation has been applied explicitly.static ScopingSINGLETON_ANNOTATIONstatic ScopingSINGLETON_INSTANCEstatic ScopingUNSCOPEDNo scoping annotation has been applied.
-
Constructor Summary
Constructors Modifier Constructor Description privateScoping()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract <V> VacceptVisitor(BindingScopingVisitor<V> visitor)abstract voidapplyTo(ScopedBindingBuilder scopedBindingBuilder)booleanequals(java.lang.Object obj)static ScopingforAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> scopingAnnotation)static ScopingforInstance(Scope scope)java.lang.Class<? extends java.lang.annotation.Annotation>getScopeAnnotation()Returns the scope annotation, ornullif that isn't known for this instance.ScopegetScopeInstance()Returns the scope instance, ornullif that isn't known for this instance.inthashCode()booleanisEagerSingleton(Stage stage)Returns true if this scope is a singleton that should be loaded eagerly instage.booleanisExplicitlyScoped()Returns true if this scope was explicitly applied.booleanisNoScope()Returns true if this is the default scope.(package private) static ScopingmakeInjectable(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, java.lang.Object source, Scoping scoping)Scopes an internal factory.
-
-
-
Field Detail
-
UNSCOPED
public static final Scoping 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
private static final Scoping EXPLICITLY_UNSCOPED
No scoping annotation has been applied explicitly. Note that this is is the same asin(Scopes.NO_SCOPE).
-
SINGLETON_ANNOTATION
public static final Scoping SINGLETON_ANNOTATION
-
SINGLETON_INSTANCE
public static final Scoping SINGLETON_INSTANCE
-
EAGER_SINGLETON
public static final Scoping EAGER_SINGLETON
-
-
Method Detail
-
forAnnotation
public static Scoping forAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> scopingAnnotation)
-
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
public boolean isEagerSingleton(Stage stage)
Returns true if this scope is a singleton that should be loaded eagerly instage.
-
getScopeInstance
public Scope getScopeInstance()
Returns the scope instance, ornullif that isn't known for this instance.
-
getScopeAnnotation
public java.lang.Class<? extends java.lang.annotation.Annotation> getScopeAnnotation()
Returns the scope annotation, ornullif that isn't known for this instance.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
acceptVisitor
public abstract <V> V acceptVisitor(BindingScopingVisitor<V> visitor)
-
applyTo
public abstract void applyTo(ScopedBindingBuilder scopedBindingBuilder)
-
scope
static <T> InternalFactory<? extends T> scope(Key<T> key, InjectorImpl injector, InternalFactory<? extends T> creator, java.lang.Object source, Scoping scoping)
Scopes an internal factory.
-
makeInjectable
static Scoping makeInjectable(Scoping scoping, InjectorImpl injector, Errors errors)
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.
-
-