1 /* 2 * Copyright (C) 2015 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.inject.multibindings; 18 19 import com.google.common.collect.ImmutableSet; 20 import com.google.inject.Binder; 21 import com.google.inject.Key; 22 import com.google.inject.Module; 23 import com.google.inject.spi.InjectionPoint; 24 import com.google.inject.spi.ModuleAnnotatedMethodScanner; 25 import com.google.inject.util.Modules; 26 import java.lang.annotation.Annotation; 27 import java.util.Set; 28 29 /** 30 * Scans a module for annotations that signal multibindings, mapbindings, and optional bindings. 31 * 32 * @since 4.0 33 * @deprecated This functionality is installed by default. All references to this can be safely 34 * removed. This class will be removed in Guice 4.4 35 */ 36 @Deprecated 37 public class MultibindingsScanner { MultibindingsScanner()38 private MultibindingsScanner() {} 39 40 /** 41 * Returns a module that, when installed, will scan all modules for methods with the annotations 42 * {@literal @}{@link ProvidesIntoMap}, {@literal @}{@link ProvidesIntoSet}, and 43 * {@literal @}{@link ProvidesIntoOptional}. 44 * 45 * <p>This is a convenience method, equivalent to doing {@code 46 * binder().scanModulesForAnnotatedMethods(MultibindingsScanner.scanner())}. 47 * 48 * @deprecated This functionality is now installed by default. All references/installations can be 49 * eliminated. 50 */ 51 @Deprecated asModule()52 public static Module asModule() { 53 return Modules.EMPTY_MODULE; 54 } 55 56 /** 57 * @deprecated This method returns an empty scanner since the preexisting functionality is 58 * installed by default. 59 */ 60 @Deprecated scanner()61 public static ModuleAnnotatedMethodScanner scanner() { 62 return new ModuleAnnotatedMethodScanner() { 63 @Override 64 public Set<? extends Class<? extends Annotation>> annotationClasses() { 65 return ImmutableSet.of(); 66 } 67 68 @Override 69 public <T> Key<T> prepareMethod( 70 Binder binder, Annotation annotation, Key<T> key, InjectionPoint injectionPoint) { 71 throw new IllegalStateException("Unexpected annotation: " + annotation); 72 } 73 }; 74 } 75 } 76