本文整理汇总了Java中com.google.inject.spi.ProviderLookup类的典型用法代码示例。如果您正苦于以下问题:Java ProviderLookup类的具体用法?Java ProviderLookup怎么用?Java ProviderLookup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProviderLookup类属于com.google.inject.spi包,在下文中一共展示了ProviderLookup类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: containsElement
import com.google.inject.spi.ProviderLookup; //导入依赖的package包/类
public boolean containsElement(com.google.inject.spi.Element element) {
if (mapBinder.containsElement(element)) {
return true;
} else {
Key<?> elementKey;
if (element instanceof Binding) {
elementKey = ((Binding<?>) element).getKey();
} else if (element instanceof ProviderLookup) {
elementKey = ((ProviderLookup<?>) element).getKey();
} else {
return false; // cannot match;
}
return elementKey.equals(optionalKey)
|| elementKey.equals(optionalProviderKey)
|| elementKey.equals(optionalJavaxProviderKey)
|| matchesTypeKey(element, elementKey)
|| matchesUserBinding(elementKey);
}
}
示例2: containsElement
import com.google.inject.spi.ProviderLookup; //导入依赖的package包/类
boolean containsElement(com.google.inject.spi.Element element) {
if (entrySetBinder.containsElement(element)) {
return true;
} else {
Key<?> key;
if (element instanceof Binding) {
key = ((Binding<?>)element).getKey();
} else if (element instanceof ProviderLookup) {
key = ((ProviderLookup<?>)element).getKey();
} else {
return false; // cannot match;
}
return key.equals(mapKey)
|| key.equals(providerMapKey)
|| key.equals(javaxProviderMapKey)
|| key.equals(multimapKey)
|| key.equals(providerMultimapKey)
|| key.equals(entrySetBinder.getSetKey())
|| matchesValueKey(key);
}
}
示例3: visit
import com.google.inject.spi.ProviderLookup; //导入依赖的package包/类
@Override
public <T> Void visit(ProviderLookup<T> providerLookup)
{
dependencyAnalyzer.addDependency(providerLookup.getKey());
providerLookup.applyTo(binder);
return null;
}
示例4: assertAllDependenciesDeclared
import com.google.inject.spi.ProviderLookup; //导入依赖的package包/类
public void assertAllDependenciesDeclared() {
List<Key> requiredKeys = new ArrayList<>();
List<Element> elements = Elements.getElements(module);
for (Element element : elements) {
element.acceptVisitor(new DefaultElementVisitor<Void>() {
@Override
public <T> Void visit(ProviderLookup<T> providerLookup) {
// Required keys are the only ones with null injection points.
if (providerLookup.getDependency().getInjectionPoint() == null) {
requiredKeys.add(providerLookup.getKey());
}
return null;
}
});
}
Injector injector = Guice.createInjector(module,
new AbstractModule() {
@Override
@SuppressWarnings("unchecked")
protected void configure() {
binder().disableCircularProxies();
binder().requireAtInjectOnConstructors();
binder().requireExactBindingAnnotations();
for (Key<?> key : requiredKeys) {
bind((Key) key).toProvider(Providers.of(null));
}
}
});
injector.getAllBindings();
}
示例5: visit
import com.google.inject.spi.ProviderLookup; //导入依赖的package包/类
@Override
public <T> Boolean visit(ProviderLookup<T> lookup) {
// ensure the provider can be created
try {
Provider<T> provider = injector.getProviderOrThrow(lookup.getDependency(), errors);
lookup.initializeDelegate(provider);
} catch (ErrorsException e) {
errors.merge(e.getErrors()); // TODO: source
}
return true;
}
示例6: visit
import com.google.inject.spi.ProviderLookup; //导入依赖的package包/类
@Override public <T> Boolean visit(ProviderLookup<T> lookup) {
// ensure the provider can be created
try {
Provider<T> provider = injector.getProviderOrThrow(lookup.getKey(), errors);
lookup.initializeDelegate(provider);
} catch (ErrorsException e) {
errors.merge(e.getErrors()); // TODO: source
}
return true;
}
示例7: visit
import com.google.inject.spi.ProviderLookup; //导入依赖的package包/类
@Override
public <T> V visit(ProviderLookup<T> lookup) {
return message(lookup,
"Looking up provider " + lookup.getProvider() +
" for key " + lookup.getKey());
}
示例8: visit
import com.google.inject.spi.ProviderLookup; //导入依赖的package包/类
@Override
public <T> Object visit(ProviderLookup<T> providerLookup) {
processDependency(providerLookup.getDependency());
return super.visit(providerLookup);
}
示例9: visit
import com.google.inject.spi.ProviderLookup; //导入依赖的package包/类
public <T> Void visit(ProviderLookup<T> providerLookup) {
// Ignore provider lookups for now
// TODO(bstoler): I guess we should error if you try to lookup a provider
// that is not bound?
return null;
}
示例10: getProvider
import com.google.inject.spi.ProviderLookup; //导入依赖的package包/类
@Override
public <T> Provider<T> getProvider(Key<T> key) {
ProviderLookup<T> lookup = new ProviderLookup<>(key, key);
lookups.add(lookup);
return lookup.getProvider();
}
示例11: getProvider
import com.google.inject.spi.ProviderLookup; //导入依赖的package包/类
public <T> Provider<T> getProvider(Key<T> key) {
ProviderLookup<T> lookup = new ProviderLookup<T>(key, key);
lookups.add(lookup);
return lookup.getProvider();
}