@Test public void testAddExecutorServiceModuleIfNotPresent() { List<Module> modules = Lists.newArrayList(); ExecutorServiceModule module = new ExecutorServiceModule(); modules.add(module); ContextBuilder.addExecutorServiceIfNotPresent(modules); assertEquals(modules.size(), 1); assertEquals(modules.remove(0), module); }
@VisibleForTesting static void addExecutorServiceIfNotPresent(List<Module> modules) { if (!any(modules, new Predicate<Module>() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(ConfiguresExecutorService.class); } } )) { if (any(modules, new Predicate<Module>() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(SingleThreaded.class); } })) { modules.add(new ExecutorServiceModule(newDirectExecutorService())); } else { modules.add(new ExecutorServiceModule()); } } }
ContextBuilder { @VisibleForTesting static void addExecutorServiceIfNotPresent(List<Module> modules) { if (!any(modules, new Predicate<Module>() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(ConfiguresExecutorService.class); } } )) { if (any(modules, new Predicate<Module>() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(SingleThreaded.class); } })) { modules.add(new ExecutorServiceModule(newDirectExecutorService())); } else { modules.add(new ExecutorServiceModule()); } } } }
ContextBuilder { @VisibleForTesting static void addExecutorServiceIfNotPresent(List<Module> modules) { if (!any(modules, new Predicate<Module>() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(ConfiguresExecutorService.class); } } )) { if (any(modules, new Predicate<Module>() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(SingleThreaded.class); } })) { modules.add(new ExecutorServiceModule(newDirectExecutorService())); } else { modules.add(new ExecutorServiceModule()); } } } protected  ContextBuilder(ProviderMetadata providerMetadata); protected  ContextBuilder(@Nullable ProviderMetadata providerMetadata, ApiMetadata apiMetadata);  ContextBuilder(ApiMetadata apiMetadata); }
ContextBuilder { @VisibleForTesting static void addExecutorServiceIfNotPresent(List<Module> modules) { if (!any(modules, new Predicate<Module>() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(ConfiguresExecutorService.class); } } )) { if (any(modules, new Predicate<Module>() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(SingleThreaded.class); } })) { modules.add(new ExecutorServiceModule(newDirectExecutorService())); } else { modules.add(new ExecutorServiceModule()); } } } protected  ContextBuilder(ProviderMetadata providerMetadata); protected  ContextBuilder(@Nullable ProviderMetadata providerMetadata, ApiMetadata apiMetadata);  ContextBuilder(ApiMetadata apiMetadata); static ContextBuilder newBuilder(String providerOrApi); static ContextBuilder newBuilder(ApiMetadata apiMetadata); static ContextBuilder newBuilder(ProviderMetadata providerMetadata); @Override String toString(); ContextBuilder name(String name); ContextBuilder credentialsSupplier(Supplier<Credentials> credentialsSupplier); ContextBuilder credentials(String identity, @Nullable String credential); ContextBuilder endpoint(String endpoint); ContextBuilder apiVersion(String apiVersion); ContextBuilder buildVersion(String buildVersion); ContextBuilder modules(Iterable<? extends Module> modules); ContextBuilder overrides(Properties overrides); static String searchPropertiesForProviderScopedProperty(Properties mutable, String prov, String key); Injector buildInjector(); static Injector buildInjector(String name, ProviderMetadata providerMetadata, Supplier<Credentials> creds, List<Module> inputModules); @SuppressWarnings("unchecked") C build(); V build(Class<V> viewType); V buildView(Class<V> viewType); @SuppressWarnings("unchecked") V buildView(TypeToken<V> viewType); @SuppressWarnings("unchecked") C build(TypeToken<C> contextType); A buildApi(Class<A> api); @SuppressWarnings("unchecked") A buildApi(TypeToken<A> apiType); ApiMetadata getApiMetadata(); }
ContextBuilder { @VisibleForTesting static void addExecutorServiceIfNotPresent(List<Module> modules) { if (!any(modules, new Predicate<Module>() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(ConfiguresExecutorService.class); } } )) { if (any(modules, new Predicate<Module>() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(SingleThreaded.class); } })) { modules.add(new ExecutorServiceModule(newDirectExecutorService())); } else { modules.add(new ExecutorServiceModule()); } } } protected  ContextBuilder(ProviderMetadata providerMetadata); protected  ContextBuilder(@Nullable ProviderMetadata providerMetadata, ApiMetadata apiMetadata);  ContextBuilder(ApiMetadata apiMetadata); static ContextBuilder newBuilder(String providerOrApi); static ContextBuilder newBuilder(ApiMetadata apiMetadata); static ContextBuilder newBuilder(ProviderMetadata providerMetadata); @Override String toString(); ContextBuilder name(String name); ContextBuilder credentialsSupplier(Supplier<Credentials> credentialsSupplier); ContextBuilder credentials(String identity, @Nullable String credential); ContextBuilder endpoint(String endpoint); ContextBuilder apiVersion(String apiVersion); ContextBuilder buildVersion(String buildVersion); ContextBuilder modules(Iterable<? extends Module> modules); ContextBuilder overrides(Properties overrides); static String searchPropertiesForProviderScopedProperty(Properties mutable, String prov, String key); Injector buildInjector(); static Injector buildInjector(String name, ProviderMetadata providerMetadata, Supplier<Credentials> creds, List<Module> inputModules); @SuppressWarnings("unchecked") C build(); V build(Class<V> viewType); V buildView(Class<V> viewType); @SuppressWarnings("unchecked") V buildView(TypeToken<V> viewType); @SuppressWarnings("unchecked") C build(TypeToken<C> contextType); A buildApi(Class<A> api); @SuppressWarnings("unchecked") A buildApi(TypeToken<A> apiType); ApiMetadata getApiMetadata();  }