/** * @deprecated This method returns an empty scanner since the preexisting functionality is * installed by default. */ @Deprecated public static ModuleAnnotatedMethodScanner scanner() { return new ModuleAnnotatedMethodScanner() { @Override public Set<? extends Class<? extends Annotation>> annotationClasses() { return ImmutableSet.of(); } @Override public <T> Key<T> prepareMethod( Binder binder, Annotation annotation, Key<T> key, InjectionPoint injectionPoint) { throw new IllegalStateException("Unexpected annotation: " + annotation); } }; }
private ProviderMethodsModule( Object delegate, boolean skipFastClassGeneration, ModuleAnnotatedMethodScanner scanner) { this.delegate = checkNotNull(delegate, "delegate"); this.typeLiteral = TypeLiteral.get(this.delegate.getClass()); this.skipFastClassGeneration = skipFastClassGeneration; this.scanner = scanner; }
private static Module forObject( Object object, boolean skipFastClassGeneration, ModuleAnnotatedMethodScanner scanner) { // avoid infinite recursion, since installing a module always installs itself if (object instanceof ProviderMethodsModule) { return Modules.EMPTY_MODULE; } return new ProviderMethodsModule(object, skipFastClassGeneration, scanner); }
@Override default void scanModulesForAnnotatedMethods(final ModuleAnnotatedMethodScanner scanner) { this.binder().scanModulesForAnnotatedMethods(scanner); }
/** Returns a module which creates bindings methods in the module that match the scanner. */ public static Module forModule(Object module, ModuleAnnotatedMethodScanner scanner) { return forObject(module, false, scanner); }
/** * Adds a scanner that will look in all installed modules for annotations the scanner can parse, * and binds them like {@literal @}Provides methods. Scanners apply to all modules installed in * the injector. Scanners installed in child injectors or private modules do not impact modules in * siblings or parents, however scanners installed in parents do apply to all child injectors and * private modules. * * @since 4.0 */ void scanModulesForAnnotatedMethods(ModuleAnnotatedMethodScanner scanner);