public static boolean inScope ( final Injector injector , final Binding < ? > binding , final Class < ? extends Annotation > scope ) { return binding . acceptScopingVisitor ( new BindingScopingVisitor < Boolean > ( ) { @ Override public Boolean visitEagerSingleton ( ) { return scope == Singleton . class || scope == javax . inject . Singleton . class ; } @ Override public Boolean visitNoScoping ( ) { return false ; } @ Override public Boolean visitScope ( Scope guiceScope ) { return injector . getScopeBindings ( ) . get ( scope ) == guiceScope ; } @ Override public Boolean visitScopeAnnotation ( Class < ? extends Annotation > scopeAnnotation ) { return scopeAnnotation == scope ; } } ) ; }
Returns true if the binding is in the specified scope false otherwise .