InjectorImpl implements Injector { @Override public <T> Optional<T> getAfter(Class<T> type, T before) { requireNonNull(type); requireNonNull(before); boolean found = false; for (Iterator<T> i = stream(type).iterator(); i.hasNext(); ) { final T t = i.next(); if (found) { return Optional.of(t); } if (t == before) { found = true; } } return Optional.empty(); } InjectorImpl(
        final Set<Injectable<?>> injectables,
        final List<Object> instances,
        final Properties properties,
        final ClassLoader classLoader,
        final DependencyGraph graph,
        final InjectorBuilder builder
    ); static InjectorBuilder builder(); static InjectorBuilder builder(ClassLoader classLoader); @Override Stream<T> stream(Class<T> type); @Override T getOrThrow(Class<T> type); @Override T getAfterOrThrow(Class<T> type, T before); @Override Optional<T> get(Class<T> type); @Override Optional<T> getAfter(Class<T> type, T before); @Override Stream<Class<?>> injectables(); @Override T inject(T instance); @Override ClassLoader classLoader(); @Override void stop(); @Override InjectorBuilder newBuilder(); static final Logger LOGGER_INSTANCE; }
@Test void getAfter() { final Foo expected = injector.getOrThrow(Bar.class); final Baz baz = injector.getOrThrow(Baz.class); final Foo actual = injector.getAfter(Foo.class, baz).orElseThrow(NoSuchElementException::new); assertEquals(expected, actual); final Bar bar = injector.getOrThrow(Bar.class); assertFalse(injector.getAfter(Foo.class, bar).isPresent()); }