Java 类com.google.inject.spi.ProviderLookup 实例源码

项目:guice-old    文件:OptionalBinder.java   
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);
  }
}
项目:guice-old    文件:MapBinder.java   
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);
    }
}
项目:Equella    文件:ElementAnalyzer.java   
@Override
public <T> Void visit(ProviderLookup<T> providerLookup)
{
    dependencyAnalyzer.addDependency(providerLookup.getKey());
    providerLookup.applyTo(binder);
    return null;
}
项目:mail-importer    文件:ModuleTester.java   
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();
}
项目:guice    文件:LookupProcessor.java   
@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;
}
项目:guice-old    文件:LookupProcessor.java   
@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;
}
项目:google-guice    文件:LookupProcessor.java   
@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;
}
项目:ProjectAres    文件:ElementInspector.java   
@Override
public <T> V visit(ProviderLookup<T> lookup) {
    return message(lookup,
                   "Looking up provider " + lookup.getProvider() +
                   " for key " + lookup.getKey());
}
项目:ProjectAres    文件:DependencyCollector.java   
@Override
public <T> Object visit(ProviderLookup<T> providerLookup) {
    processDependency(providerLookup.getDependency());
    return super.visit(providerLookup);
}
项目:google-gin    文件:GuiceElementVisitor.java   
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;
}
项目:guice    文件:DeferredLookups.java   
@Override
public <T> Provider<T> getProvider(Key<T> key) {
  ProviderLookup<T> lookup = new ProviderLookup<>(key, key);
  lookups.add(lookup);
  return lookup.getProvider();
}
项目:guice-old    文件:DeferredLookups.java   
public <T> Provider<T> getProvider(Key<T> key) {
  ProviderLookup<T> lookup = new ProviderLookup<T>(key, key);
  lookups.add(lookup);
  return lookup.getProvider();
}
项目:google-guice    文件:DeferredLookups.java   
public <T> Provider<T> getProvider(Key<T> key) {
  ProviderLookup<T> lookup = new ProviderLookup<T>(key, key);
  lookups.add(lookup);
  return lookup.getProvider();
}