com.google.inject.internal.LookupProcessor Maven / Gradle / Ivy
package com.google.inject.internal;
import com.google.inject.MembersInjector;
import com.google.inject.Provider;
import com.google.inject.spi.MembersInjectorLookup;
import com.google.inject.spi.ProviderLookup;
/**
* Handles {@code Binder.getProvider} and {@code Binder.getMembersInjector(TypeLiteral)} commands.
*/
final class LookupProcessor extends AbstractProcessor {
LookupProcessor(Errors errors) {
super(errors);
}
@Override
public Boolean visit(MembersInjectorLookup lookup) {
try {
MembersInjector membersInjector
= injector.membersInjectorStore.get(lookup.getType(), errors);
lookup.initializeDelegate(membersInjector);
} catch (ErrorsException e) {
errors.merge(e.getErrors()); // TODO: source
}
return true;
}
@Override
public Boolean visit(ProviderLookup lookup) {
// ensure the provider can be created
try {
Provider provider = injector.getProviderOrThrow(lookup.getDependency(), errors);
lookup.initializeDelegate(provider);
} catch (ErrorsException e) {
errors.merge(e.getErrors()); // TODO: source
}
return true;
}
}