Top Description Inners Fields Constructors Methods
com.google.inject.internal

pack-priv final Class ProvidesMethodScanner

extends ModuleAnnotatedMethodScanner
Class Inheritance
Imports
com.google.common.collect.ImmutableSet, com.google.inject.Binder, .Key, .Provides, .TypeLiteral, com.google.inject.multibindings.MapKey, .ProvidesIntoMap, .ProvidesIntoOptional, .ProvidesIntoSet, com.google.inject.spi.InjectionPoint, .ModuleAnnotatedMethodScanner, java.lang.annotation.Annotation, java.lang.reflect.InvocationTargetException, .Method, java.util.Set

A ModuleAnnotatedMethodScanner that handles the {@Provides }, ProvidesIntoSet, ProvidesIntoMap and ProvidesIntoOptional annotations.

This is the default scanner used by ProviderMethodsModule and handles all the built in annotations.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final ImmutableSet<Class<? extends Annotation>>
pack-priv static final ProvidesMethodScanner

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Set<? extends Class<? extends Annotation>>
annotationClasses()

Implements abstract com.google.inject.spi.ModuleAnnotatedMethodScanner.annotationClasses.

Returns the annotations this should scan for.
private static ProvidesMethodScanner.AnnotationOrError
public <T> Key<T>
prepareMethod(Binder binder, Annotation annotation, Key<T> key, InjectionPoint injectionPoint)

Implements abstract com.google.inject.spi.ModuleAnnotatedMethodScanner.prepareMethod.

Prepares a method for binding.
pack-priv static ProvidesMethodScanner.TypeAndValue<?>
typeAndValueOfMapKey(Annotation mapKeyAnnotation)

Field Detail

ANNOTATIONSback to summary
private static final ImmutableSet<Class<? extends Annotation>> ANNOTATIONS
INSTANCEback to summary
pack-priv static final ProvidesMethodScanner INSTANCE

Constructor Detail

ProvidesMethodScannerback to summary
private ProvidesMethodScanner()

Method Detail

annotationClassesback to summary
public Set<? extends Class<? extends Annotation>> annotationClasses()

Implements abstract com.google.inject.spi.ModuleAnnotatedMethodScanner.annotationClasses.

Doc from com.google.inject.spi.ModuleAnnotatedMethodScanner.annotationClasses.

Returns 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.

Annotations
@Override
findMapKeyAnnotationback to summary
private static ProvidesMethodScanner.AnnotationOrError findMapKeyAnnotation(Binder binder, Method method)
prepareMethodback to summary
public <T> Key<T> prepareMethod(Binder binder, Annotation annotation, Key<T> key, InjectionPoint injectionPoint)

Implements abstract com.google.inject.spi.ModuleAnnotatedMethodScanner.prepareMethod.

Doc from com.google.inject.spi.ModuleAnnotatedMethodScanner.prepareMethod.

Prepares a method for binding. This key parameter 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 binding String.

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 annotationClasses.

Returning null will cause Guice to skip this method, so that it is not bound to any key.

If injectionPoint represents an abstract method, null must be returned from this method. This scanner can use binder to bind alternative bindings in place of the abstract method.

Annotations
@SuppressWarnings:unchecked, rawtypes
@Override
typeAndValueOfMapKeyback to summary
pack-priv static ProvidesMethodScanner.TypeAndValue<?> typeAndValueOfMapKey(Annotation mapKeyAnnotation)
Annotations
@SuppressWarnings:unchecked, rawtypes
com.google.inject.internal back to summary

private Class ProvidesMethodScanner.AnnotationOrError

extends Object
Class Inheritance
  • java.lang.Object
  • com.google.inject.internal.ProvidesMethodScanner.AnnotationOrError

Field Summary

Modifier and TypeField and Description
pack-priv final Annotation
pack-priv final boolean

Constructor Summary

AccessConstructor and Description
pack-priv
AnnotationOrError(Annotation annotation, boolean error)

Method Summary

Modifier and TypeMethod and Description
pack-priv static ProvidesMethodScanner.AnnotationOrError
pack-priv static ProvidesMethodScanner.AnnotationOrError
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

annotationback to summary
pack-priv final Annotation annotation
errorback to summary
pack-priv final boolean error

Constructor Detail

AnnotationOrErrorback to summary
pack-priv AnnotationOrError(Annotation annotation, boolean error)

Method Detail

forErrorback to summary
pack-priv static ProvidesMethodScanner.AnnotationOrError forError()
forPossiblyNullAnnotationback to summary
pack-priv static ProvidesMethodScanner.AnnotationOrError forPossiblyNullAnnotation(Annotation annotation)
com.google.inject.internal back to summary

private Class ProvidesMethodScanner.TypeAndValue<T>

extends Object
Class Inheritance
  • java.lang.Object
  • com.google.inject.internal.ProvidesMethodScanner.TypeAndValue

Field Summary

Modifier and TypeField and Description
pack-priv final TypeLiteral<T>
pack-priv final T

Constructor Summary

AccessConstructor and Description
pack-priv
TypeAndValue(TypeLiteral<T> type, T value)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

typeback to summary
pack-priv final TypeLiteral<T> type
valueback to summary
pack-priv final T value

Constructor Detail

TypeAndValueback to summary
pack-priv TypeAndValue(TypeLiteral<T> type, T value)