public class Scopes
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static BindingScopingVisitor<java.lang.Boolean> |
IS_SINGLETON_VISITOR |
static Scope |
NO_SCOPE
No scope; the same as not applying any scope at all.
|
static Scope |
SINGLETON
One instance per
Injector . |
Modifier | Constructor and Description |
---|---|
private |
Scopes() |
Modifier and Type | Method and Description |
---|---|
static boolean |
isCircularProxy(java.lang.Object object)
Returns true if the object is a proxy for a circular dependency,
constructed by Guice because it encountered a circular dependency.
|
static boolean |
isScoped(Binding<?> binding,
Scope scope,
java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation)
Returns true if
binding has the given scope. |
static boolean |
isSingleton(Binding<?> binding)
Returns true if
binding is singleton-scoped. |
public static final Scope SINGLETON
public static final Scope NO_SCOPE
This exists only in case a class has been annotated with a scope
annotation such as @Singleton
, and you need to override
this to "no scope" in your binding.
private static final BindingScopingVisitor<java.lang.Boolean> IS_SINGLETON_VISITOR
public static boolean isSingleton(Binding<?> binding)
binding
is singleton-scoped. If the binding is a linked key binding
and belongs to an injector (ie. it
was retrieved via Injector.getBinding()
), then this method will
also true if the target binding is singleton-scoped.public static boolean isScoped(Binding<?> binding, Scope scope, java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation)
binding
has the given scope. If the binding is a linked key binding
and belongs to an injector (ie. it
was retrieved via Injector.getBinding()
), then this method will
also true if the target binding has the given scope.binding
- binding to checkscope
- scope implementation instancescopeAnnotation
- scope annotation classpublic static boolean isCircularProxy(java.lang.Object object)