Class ProviderMethodsModule

  • All Implemented Interfaces:
    Module

    public final class ProviderMethodsModule
    extends java.lang.Object
    implements Module
    Creates bindings to methods annotated with @Provides. Use the scope and binding annotations on the provider method to configure the binding.
    • Field Detail

      • delegate

        private final java.lang.Object delegate
      • typeLiteral

        private final TypeLiteral<?> typeLiteral
      • skipFastClassGeneration

        private final boolean skipFastClassGeneration
    • Constructor Detail

      • ProviderMethodsModule

        private ProviderMethodsModule​(java.lang.Object delegate,
                                      boolean skipFastClassGeneration,
                                      ModuleAnnotatedMethodScanner scanner)
    • Method Detail

      • forModule

        public static Module forModule​(Module module)
        Returns a module which creates bindings for provider methods from the given module.
      • forModule

        public static Module forModule​(java.lang.Object module,
                                       ModuleAnnotatedMethodScanner scanner)
        Returns a module which creates bindings methods in the module that match the scanner.
      • forObject

        public static Module forObject​(java.lang.Object object)
        Returns a module which creates bindings for provider methods from the given object. This is useful notably for GIN

        This will skip bytecode generation for provider methods, since it is assumed that callers are only interested in Module metadata.

      • getDelegateModuleClass

        public java.lang.Class<?> getDelegateModuleClass()
      • isStaticModule

        private boolean isStaticModule()
      • configure

        public void configure​(Binder binder)
        Description copied from interface: Module
        Contributes bindings and other configurations for this module to binder.

        Do not invoke this method directly to install submodules. Instead use Binder.install(Module), which ensures that provider methods are discovered.

        Specified by:
        configure in interface Module
      • getProviderMethods

        public java.util.List<ProviderMethod<?>> getProviderMethods​(Binder binder)
      • getAnnotation

        private java.lang.annotation.Annotation getAnnotation​(Binder binder,
                                                              java.lang.reflect.Method method)
        Returns the annotation that is claimed by the scanner, or null if there is none.
      • overrides

        private static boolean overrides​(java.lang.reflect.Method a,
                                         java.lang.reflect.Method b)
        Returns true if a overrides b, assumes that the signatures match
      • createProviderMethod

        private <T> ProviderMethod<T> createProviderMethod​(Binder binder,
                                                           java.lang.reflect.Method method,
                                                           java.lang.annotation.Annotation annotation)
      • getKey

        <T> Key<T> getKey​(Errors errors,
                          TypeLiteral<T> type,
                          java.lang.reflect.Member member,
                          java.lang.annotation.Annotation[] annotations)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object