Example #1
0
 @Override
 public Logger supply(Dependency<? super Logger> dependency, Injector injector) {
   if (dependency.isUntargeted()) {
     return LoggerFactory.getLogger("General");
   } else {
     return LoggerFactory.getLogger(dependency.target().getType().getRawType());
   }
 }
Example #2
0
 @Override
 public Provider<?> supply(Dependency<? super Provider<?>> dependency, Injector injector) {
   Dependency<?> providedType = dependency.onTypeParameter();
   if (!dependency.getName().isDefault()) {
     providedType = providedType.named(dependency.getName());
   }
   return newProvider(providedType, injector);
 }
Example #3
0
 @Override
 public T supply(Dependency<? super T> dependency, Injector injector) {
   Type<? super T> type = dependency.getType();
   Instance<? extends T> parametrized =
       instance.typed(
           instance
               .getType()
               .parametized(type.getParameters())
               .lowerBound(dependency.getType().isLowerBound()));
   return injector.resolve(dependency.instanced(parametrized));
 }
Example #4
0
 @SuppressWarnings("unchecked")
 @Override
 public E[] supply(Dependency<? super E[]> dependency, Injector injector) {
   E[] res = (E[]) Array.newInstance(arrayType.getComponentType(), elements.length);
   int i = 0;
   final Dependency<E> elementDependency =
       (Dependency<E>) dependency.typed(Type.raw(arrayType).elementType());
   for (Supplier<? extends E> e : elements) {
     res[i++] = e.supply(elementDependency, injector);
   }
   return res;
 }
Example #5
0
 @Override
 public T supply(Dependency<? super T> dependency, Injector injector) {
   return factory.produce(dependency.getInstance(), dependency.target(1));
 }
Example #6
0
 @Override
 public T supply(Dependency<? super T> dependency, Injector injector) {
   return injector.resolve(dependency.instanced(instance));
 }
Example #7
0
 @Override
 public T supply(Dependency<? super T> dependency, Injector injector) {
   final Supplier<? extends T> supplier = injector.resolve(dependency.anyTyped(type));
   return supplier.supply(dependency, injector);
 }
Example #8
0
 @Override
 public final T supply(Dependency<? super T> dependency, Injector injector) {
   Type<?> elementType = dependency.getType().parameter(0);
   return bridge(supplyArray(dependency.anyTyped(elementType.getArrayType()), injector));
 }