Package com.google.inject.internal
Class EncounterImpl<T>
java.lang.Object
com.google.inject.internal.EncounterImpl<T>
- All Implemented Interfaces:
TypeEncounter<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Errors
private List<InjectionListener<? super T>>
private final Lookups
private List<MembersInjector<? super T>>
private boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Records an error message to be presented to the user at a later time.void
Records an error message for typeI
which will be presented to the user at a later time.void
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.(package private) com.google.common.collect.ImmutableSet<InjectionListener<? super T>>
<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> MembersInjector<T>
getMembersInjector
(Class<T> type) Returns the members injector used to inject dependencies into methods and fields on instances of the given typeT
.(package private) com.google.common.collect.ImmutableSet<MembersInjector<? super T>>
<T> Provider<T>
getProvider
(Key<T> key) Returns the provider used to obtain instances for the given injection key.<T> Provider<T>
getProvider
(Class<T> type) Returns the provider used to obtain instances for the given injection type.(package private) void
void
register
(MembersInjector<? super T> membersInjector) Registers a members injector for typeI
.void
register
(InjectionListener<? super T> injectionListener) Registers an injection listener for typeI
.
-
Field Details
-
errors
-
lookups
-
membersInjectors
-
injectionListeners
-
valid
private boolean valid
-
-
Constructor Details
-
EncounterImpl
-
-
Method Details
-
invalidate
void invalidate() -
getMembersInjectors
com.google.common.collect.ImmutableSet<MembersInjector<? super T>> getMembersInjectors() -
getInjectionListeners
com.google.common.collect.ImmutableSet<InjectionListener<? super T>> getInjectionListeners() -
register
Description copied from interface:TypeEncounter
Registers a members injector for typeI
. Guice will use the members injector after its performed its own injections on an instance ofI
.- Specified by:
register
in interfaceTypeEncounter<T>
-
register
Description copied from interface:TypeEncounter
Registers an injection listener for typeI
. Guice will notify the listener after all injections have been performed on an instance ofI
.- Specified by:
register
in interfaceTypeEncounter<T>
-
addError
Description copied from interface:TypeEncounter
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.- Specified by:
addError
in interfaceTypeEncounter<T>
-
addError
Description copied from interface:TypeEncounter
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.- Specified by:
addError
in interfaceTypeEncounter<T>
-
addError
Description copied from interface:TypeEncounter
Records an error message to be presented to the user at a later time.- Specified by:
addError
in interfaceTypeEncounter<T>
-
getProvider
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 anIllegalStateException
if you try to use it beforehand.- Specified by:
getProvider
in interfaceTypeEncounter<T>
-
getProvider
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 anIllegalStateException
if you try to use it beforehand.- Specified by:
getProvider
in interfaceTypeEncounter<T>
-
getMembersInjector
Description copied from interface:TypeEncounter
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.- Specified by:
getMembersInjector
in interfaceTypeEncounter<T>
- Parameters:
typeLiteral
- type to get members injector for
-
getMembersInjector
Description copied from interface:TypeEncounter
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.- Specified by:
getMembersInjector
in interfaceTypeEncounter<T>
- Parameters:
type
- type to get members injector for
-