@Test public void withUrlWhenProviderMissingStringCtor() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("FooProvider does not have a String parameter constructor"); Providers.withUrl(new FooProvider(), "http: }
public static Provider withUrl(Provider provider, String url) { checkNotNull(provider, "provider"); checkNotNull(url, "url"); try { Constructor<?> ctor = provider.getClass().getDeclaredConstructor(String.class); ctor.setAccessible(true); return Provider.class.cast(ctor.newInstance(url)); } catch (NoSuchMethodException e) { throw new IllegalArgumentException( provider.getClass() + " does not have a String parameter constructor", e); } catch (Exception e) { throw new IllegalArgumentException( "exception attempting to instantiate " + provider.getClass() + " for provider " + provider, e); } }
Providers { public static Provider withUrl(Provider provider, String url) { checkNotNull(provider, "provider"); checkNotNull(url, "url"); try { Constructor<?> ctor = provider.getClass().getDeclaredConstructor(String.class); ctor.setAccessible(true); return Provider.class.cast(ctor.newInstance(url)); } catch (NoSuchMethodException e) { throw new IllegalArgumentException( provider.getClass() + " does not have a String parameter constructor", e); } catch (Exception e) { throw new IllegalArgumentException( "exception attempting to instantiate " + provider.getClass() + " for provider " + provider, e); } } }
Providers { public static Provider withUrl(Provider provider, String url) { checkNotNull(provider, "provider"); checkNotNull(url, "url"); try { Constructor<?> ctor = provider.getClass().getDeclaredConstructor(String.class); ctor.setAccessible(true); return Provider.class.cast(ctor.newInstance(url)); } catch (NoSuchMethodException e) { throw new IllegalArgumentException( provider.getClass() + " does not have a String parameter constructor", e); } catch (Exception e) { throw new IllegalArgumentException( "exception attempting to instantiate " + provider.getClass() + " for provider " + provider, e); } }  }
Providers { public static Provider withUrl(Provider provider, String url) { checkNotNull(provider, "provider"); checkNotNull(url, "url"); try { Constructor<?> ctor = provider.getClass().getDeclaredConstructor(String.class); ctor.setAccessible(true); return Provider.class.cast(ctor.newInstance(url)); } catch (NoSuchMethodException e) { throw new IllegalArgumentException( provider.getClass() + " does not have a String parameter constructor", e); } catch (Exception e) { throw new IllegalArgumentException( "exception attempting to instantiate " + provider.getClass() + " for provider " + provider, e); } }  static Iterable<Provider> list(); static Provider getByName(String providerName); static Provider withUrl(Provider provider, String url); static Object instantiateModule(Provider in); static Object provide(denominator.Provider provider); }
Providers { public static Provider withUrl(Provider provider, String url) { checkNotNull(provider, "provider"); checkNotNull(url, "url"); try { Constructor<?> ctor = provider.getClass().getDeclaredConstructor(String.class); ctor.setAccessible(true); return Provider.class.cast(ctor.newInstance(url)); } catch (NoSuchMethodException e) { throw new IllegalArgumentException( provider.getClass() + " does not have a String parameter constructor", e); } catch (Exception e) { throw new IllegalArgumentException( "exception attempting to instantiate " + provider.getClass() + " for provider " + provider, e); } }  static Iterable<Provider> list(); static Provider getByName(String providerName); static Provider withUrl(Provider provider, String url); static Object instantiateModule(Provider in); static Object provide(denominator.Provider provider);  }