Package com.google.inject.internal
Class ProvidesMethodScanner
java.lang.Object
com.google.inject.spi.ModuleAnnotatedMethodScanner
com.google.inject.internal.ProvidesMethodScanner
A
ModuleAnnotatedMethodScanner that handles the , ProvidesIntoSet,
ProvidesIntoMap and ProvidesIntoOptional annotations.
This is the default scanner used by ProviderMethodsModule and handles all the built in annotations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final com.google.common.collect.ImmutableSet<Class<? extends Annotation>>(package private) static final ProvidesMethodScanner -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSet<? extends Class<? extends Annotation>>Returns the annotations this should scan for.private static ProvidesMethodScanner.AnnotationOrErrorfindMapKeyAnnotation(Binder binder, Method method) <T> Key<T>prepareMethod(Binder binder, Annotation annotation, Key<T> key, InjectionPoint injectionPoint) Prepares a method for binding.(package private) static ProvidesMethodScanner.TypeAndValue<?>typeAndValueOfMapKey(Annotation mapKeyAnnotation)
-
Field Details
-
INSTANCE
-
ANNOTATIONS
private static final com.google.common.collect.ImmutableSet<Class<? extends Annotation>> ANNOTATIONS
-
-
Constructor Details
-
ProvidesMethodScanner
private ProvidesMethodScanner()
-
-
Method Details
-
annotationClasses
Description copied from class:ModuleAnnotatedMethodScannerReturns the annotations this should scan for. Every method in the module that has one of these annotations will create a Provider binding, with the return value of the binding being what's provided and the parameters of the method being dependencies of the provider.- Specified by:
annotationClassesin classModuleAnnotatedMethodScanner
-
prepareMethod
public <T> Key<T> prepareMethod(Binder binder, Annotation annotation, Key<T> key, InjectionPoint injectionPoint) Description copied from class:ModuleAnnotatedMethodScannerPrepares a method for binding. Thiskeyparameter is the key discovered from looking at the binding annotation and return value of the method. Implementations can modify the key to instead bind to another key. For example, Multibinder may want to change@ProvidesIntoSet String provideFoo()to bind into a unique Key within the multibinder instead of bindingString.The injection point and annotation are provided in case the implementation wants to set the key based on the property of the annotation or if any additional preparation is needed for any of the dependencies. The annotation is guaranteed to be an instance of one the classes returned by
ModuleAnnotatedMethodScanner.annotationClasses().If
injectionPointrepresents anabstractmethod,nullmust be returned from this method. This scanner can usebinderto bind alternative bindings in place of the abstract method. In all other cases, this method may not return null.- Specified by:
prepareMethodin classModuleAnnotatedMethodScanner
-
findMapKeyAnnotation
private static ProvidesMethodScanner.AnnotationOrError findMapKeyAnnotation(Binder binder, Method method) -
typeAndValueOfMapKey
-