Class EncounterImpl<T>

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addError​(Message message)
      Records an error message to be presented to the user at a later time.
      void addError​(java.lang.String message, java.lang.Object... arguments)
      Records an error message for type I which will be presented to the user at a later time.
      void addError​(java.lang.Throwable t)
      Records an exception for type I, the full details of which will be logged, and the message of which will be presented to the user at a later time.
      void bindInterceptor​(Matcher<? super java.lang.reflect.Method> methodMatcher, org.aopalliance.intercept.MethodInterceptor... interceptors)
      Binds method interceptor[s] to methods matched in type I and its supertypes.
      (package private) com.google.common.collect.ImmutableList<MethodAspect> getAspects()  
      (package private) com.google.common.collect.ImmutableSet<InjectionListener<? super T>> getInjectionListeners()  
      <T> MembersInjector<T> getMembersInjector​(TypeLiteral<T> typeLiteral)
      Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
      <T> MembersInjector<T> getMembersInjector​(java.lang.Class<T> type)
      Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
      (package private) com.google.common.collect.ImmutableSet<MembersInjector<? super T>> getMembersInjectors()  
      <T> Provider<T> getProvider​(Key<T> key)
      Returns the provider used to obtain instances for the given injection key.
      <T> Provider<T> getProvider​(java.lang.Class<T> type)
      Returns the provider used to obtain instances for the given injection type.
      (package private) void invalidate()  
      void register​(MembersInjector<? super T> membersInjector)
      Registers a members injector for type I.
      void register​(InjectionListener<? super T> injectionListener)
      Registers an injection listener for type I.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • errors

        private final Errors errors
      • lookups

        private final Lookups lookups
      • membersInjectors

        private java.util.List<MembersInjector<? super T>> membersInjectors
      • injectionListeners

        private java.util.List<InjectionListener<? super T>> injectionListeners
      • valid

        private boolean valid
    • Constructor Detail

      • EncounterImpl

        EncounterImpl​(Errors errors,
                      Lookups lookups)
    • Method Detail

      • invalidate

        void invalidate()
      • getAspects

        com.google.common.collect.ImmutableList<MethodAspect> getAspects()
      • bindInterceptor

        public void bindInterceptor​(Matcher<? super java.lang.reflect.Method> methodMatcher,
                                    org.aopalliance.intercept.MethodInterceptor... interceptors)
        Description copied from interface: TypeEncounter
        Binds method interceptor[s] to methods matched in type I and its supertypes. A method is eligible for interception if:
        • Guice created the instance the method is on
        • Neither the enclosing type nor the method is final
        • And the method is package-private or more accessible
        Specified by:
        bindInterceptor in interface TypeEncounter<T>
        Parameters:
        methodMatcher - matches methods the interceptor should apply to. For example: annotatedWith(Transactional.class).
        interceptors - to bind
      • getMembersInjectors

        com.google.common.collect.ImmutableSet<MembersInjector<? super T>> getMembersInjectors()
      • getInjectionListeners

        com.google.common.collect.ImmutableSet<InjectionListener<? super T>> getInjectionListeners()
      • register

        public void register​(MembersInjector<? super T> membersInjector)
        Description copied from interface: TypeEncounter
        Registers a members injector for type I. Guice will use the members injector after its performed its own injections on an instance of I.
        Specified by:
        register in interface TypeEncounter<T>
      • register

        public void register​(InjectionListener<? super T> injectionListener)
        Description copied from interface: TypeEncounter
        Registers an injection listener for type I. Guice will notify the listener after all injections have been performed on an instance of I.
        Specified by:
        register in interface TypeEncounter<T>
      • addError

        public void addError​(java.lang.String message,
                             java.lang.Object... arguments)
        Description copied from interface: TypeEncounter
        Records an error message for type I which will be presented to the user at a later time. Unlike throwing an exception, this enable us to continue configuring the Injector and discover more errors. Uses String.format(String, Object[]) to insert the arguments into the message.
        Specified by:
        addError in interface TypeEncounter<T>
      • addError

        public void addError​(java.lang.Throwable t)
        Description copied from interface: TypeEncounter
        Records an exception for type I, the full details of which will be logged, and the message of which will be presented to the user at a later time. If your type listener calls something that you worry may fail, you should catch the exception and pass it to this method.
        Specified by:
        addError in interface TypeEncounter<T>
      • addError

        public void addError​(Message message)
        Description copied from interface: TypeEncounter
        Records an error message to be presented to the user at a later time.
        Specified by:
        addError in interface TypeEncounter<T>
      • getProvider

        public <T> Provider<T> getProvider​(Key<T> key)
        Description copied from interface: TypeEncounter
        Returns the provider used to obtain instances for the given injection key. The returned provider will not be valid until the injector has been created. The provider will throw an IllegalStateException if you try to use it beforehand.
        Specified by:
        getProvider in interface TypeEncounter<T>
      • getProvider

        public <T> Provider<T> getProvider​(java.lang.Class<T> type)
        Description copied from interface: TypeEncounter
        Returns the provider used to obtain instances for the given injection type. The returned provider will not be valid until the injector has been created. The provider will throw an IllegalStateException if you try to use it beforehand.
        Specified by:
        getProvider in interface TypeEncounter<T>
      • getMembersInjector

        public <T> MembersInjector<T> getMembersInjector​(TypeLiteral<T> typeLiteral)
        Description copied from interface: TypeEncounter
        Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. The returned members injector will not be valid until the main injector has been created. The members injector will throw an IllegalStateException if you try to use it beforehand.
        Specified by:
        getMembersInjector in interface TypeEncounter<T>
        Parameters:
        typeLiteral - type to get members injector for
      • getMembersInjector

        public <T> MembersInjector<T> getMembersInjector​(java.lang.Class<T> type)
        Description copied from interface: TypeEncounter
        Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. The returned members injector will not be valid until the main injector has been created. The members injector will throw an IllegalStateException if you try to use it beforehand.
        Specified by:
        getMembersInjector in interface TypeEncounter<T>
        Parameters:
        type - type to get members injector for