@Test public void container_withCyclicProviderDependency_shouldProperlyInitialize() { ComponentRuntime runtime = new ComponentRuntime( EXECUTOR, Collections.emptyList(), Component.builder(CyclicOne.class) .add(Dependency.required(CyclicTwo.class)) .factory(container -> new CyclicOne(container.get(CyclicTwo.class))) .build(), Component.builder(CyclicTwo.class) .add(Dependency.requiredProvider(CyclicOne.class)) .factory(container -> new CyclicTwo(container.getProvider(CyclicOne.class))) .build()); CyclicOne one = runtime.get(CyclicOne.class); assertThat(one.cyclicTwo).isNotNull(); Provider<CyclicOne> oneProvider = one.cyclicTwo.cyclicOne; assertThat(oneProvider).isNotNull(); assertThat(oneProvider.get()).isSameInstanceAs(one); }
@Override @SuppressWarnings("unchecked") public <T> Provider<T> getProvider(Class<T> anInterface) { Preconditions.checkNotNull(anInterface, "Null interface requested."); return (Provider<T>) lazyInstanceMap.get(anInterface); }
ComponentRuntime extends AbstractComponentContainer { @Override @SuppressWarnings("unchecked") public <T> Provider<T> getProvider(Class<T> anInterface) { Preconditions.checkNotNull(anInterface, "Null interface requested."); return (Provider<T>) lazyInstanceMap.get(anInterface); } }
ComponentRuntime extends AbstractComponentContainer { @Override @SuppressWarnings("unchecked") public <T> Provider<T> getProvider(Class<T> anInterface) { Preconditions.checkNotNull(anInterface, "Null interface requested."); return (Provider<T>) lazyInstanceMap.get(anInterface); } ComponentRuntime(
      Executor defaultEventExecutor,
      Iterable<ComponentRegistrar> registrars,
      Component<?>... additionalComponents); }
ComponentRuntime extends AbstractComponentContainer { @Override @SuppressWarnings("unchecked") public <T> Provider<T> getProvider(Class<T> anInterface) { Preconditions.checkNotNull(anInterface, "Null interface requested."); return (Provider<T>) lazyInstanceMap.get(anInterface); } ComponentRuntime(
      Executor defaultEventExecutor,
      Iterable<ComponentRegistrar> registrars,
      Component<?>... additionalComponents); @Override @SuppressWarnings("unchecked") Provider<T> getProvider(Class<T> anInterface); @Override @SuppressWarnings("unchecked") Provider<Set<T>> setOfProvider(Class<T> anInterface); void initializeEagerComponents(boolean isDefaultApp); @VisibleForTesting @RestrictTo(Scope.TESTS) void initializeAllComponentsForTests(); }
ComponentRuntime extends AbstractComponentContainer { @Override @SuppressWarnings("unchecked") public <T> Provider<T> getProvider(Class<T> anInterface) { Preconditions.checkNotNull(anInterface, "Null interface requested."); return (Provider<T>) lazyInstanceMap.get(anInterface); } ComponentRuntime(
      Executor defaultEventExecutor,
      Iterable<ComponentRegistrar> registrars,
      Component<?>... additionalComponents); @Override @SuppressWarnings("unchecked") Provider<T> getProvider(Class<T> anInterface); @Override @SuppressWarnings("unchecked") Provider<Set<T>> setOfProvider(Class<T> anInterface); void initializeEagerComponents(boolean isDefaultApp); @VisibleForTesting @RestrictTo(Scope.TESTS) void initializeAllComponentsForTests();  }