Interface TypeEncounter<I>
-
- Type Parameters:
I
- the injectable type encountered
public interface TypeEncounter<I>
Context of an injectable type encounter. Enables reporting errors, registering injection listeners and binding method interceptors for injectable typeI
. It is an error to use an encounter after thehear()
method has returned.- Since:
- 2.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addError(java.lang.String message, java.lang.Object... arguments)
Records an error message for typeI
which will be presented to the user at a later time.void
addError(java.lang.Throwable t)
Records an exception for typeI
, the full details of which will be logged, and the message of which will be presented to the user at a later time.void
addError(Message message)
Records an error message to be presented to the user at a later time.<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 typeT
.<T> MembersInjector<T>
getMembersInjector(TypeLiteral<T> typeLiteral)
Returns the members injector used to inject dependencies into methods and fields on instances of the given typeT
.<T> Provider<T>
getProvider(java.lang.Class<T> type)
Returns the provider used to obtain instances for the given injection type.<T> Provider<T>
getProvider(Key<T> key)
Returns the provider used to obtain instances for the given injection key.void
register(MembersInjector<? super I> membersInjector)
Registers a members injector for typeI
.void
register(InjectionListener<? super I> listener)
Registers an injection listener for typeI
.
-
-
-
Method Detail
-
addError
void addError(java.lang.String message, java.lang.Object... arguments)
Records an error message for typeI
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. UsesString.format(String, Object[])
to insert the arguments into the message.
-
addError
void addError(java.lang.Throwable t)
Records an exception for typeI
, 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.
-
addError
void addError(Message message)
Records an error message to be presented to the user at a later time.
-
getProvider
<T> Provider<T> getProvider(Key<T> key)
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 anIllegalStateException
if you try to use it beforehand.
-
getProvider
<T> Provider<T> getProvider(java.lang.Class<T> type)
Returns the provider used to obtain instances for the given injection type. The returned provider will not be valid until the injetor has been created. The provider will throw anIllegalStateException
if you try to use it beforehand.
-
getMembersInjector
<T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral)
Returns the members injector used to inject dependencies into methods and fields on instances of the given typeT
. The returned members injector will not be valid until the main injector has been created. The members injector will throw anIllegalStateException
if you try to use it beforehand.- Parameters:
typeLiteral
- type to get members injector for
-
getMembersInjector
<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 typeT
. The returned members injector will not be valid until the main injector has been created. The members injector will throw anIllegalStateException
if you try to use it beforehand.- Parameters:
type
- type to get members injector for
-
register
void register(MembersInjector<? super I> membersInjector)
Registers a members injector for typeI
. Guice will use the members injector after its performed its own injections on an instance ofI
.
-
register
void register(InjectionListener<? super I> listener)
Registers an injection listener for typeI
. Guice will notify the listener after all injections have been performed on an instance ofI
.
-
-