@Test public void foreach() { Consumer<? super SampleService> c = mock(Consumer.class); sampleServiceServiceLoader.forEach(c); verify(c, times(2)).accept(any(SampleService.class)); }
public void forEach(Consumer<? super S> action) { stream() .map(ServiceLoader.Provider::get) .forEach(action); }
ServiceLoaderExt { public void forEach(Consumer<? super S> action) { stream() .map(ServiceLoader.Provider::get) .forEach(action); } }
ServiceLoaderExt { public void forEach(Consumer<? super S> action) { stream() .map(ServiceLoader.Provider::get) .forEach(action); } private  ServiceLoaderExt(ServiceLoader<S> serviceLoader); }
ServiceLoaderExt { public void forEach(Consumer<? super S> action) { stream() .map(ServiceLoader.Provider::get) .forEach(action); } private  ServiceLoaderExt(ServiceLoader<S> serviceLoader); static ServiceLoaderExt<S> load(Class<S> service, ClassLoader loader); static ServiceLoaderExt<S> load(Class<S> service); static ServiceLoaderExt<S> loadInstalled(Class<S> service); static ServiceLoaderExt<S> load(ModuleLayer layer, Class<S> service); Optional<S> findFirst(); void reload(); void forEach(Consumer<? super S> action); Spliterator<S> spliterator(); Iterator<S> iterator(); Stream<ServiceLoader.Provider<S>> stream(); }
ServiceLoaderExt { public void forEach(Consumer<? super S> action) { stream() .map(ServiceLoader.Provider::get) .forEach(action); } private  ServiceLoaderExt(ServiceLoader<S> serviceLoader); static ServiceLoaderExt<S> load(Class<S> service, ClassLoader loader); static ServiceLoaderExt<S> load(Class<S> service); static ServiceLoaderExt<S> loadInstalled(Class<S> service); static ServiceLoaderExt<S> load(ModuleLayer layer, Class<S> service); Optional<S> findFirst(); void reload(); void forEach(Consumer<? super S> action); Spliterator<S> spliterator(); Iterator<S> iterator(); Stream<ServiceLoader.Provider<S>> stream();  }