@Test public void shouldInstantiateNotAccessibleWithCRestConfig() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { NotAccessiblePublicClassWithCRestConfig actual = ComponentFactory.instantiate(NotAccessiblePublicClassWithCRestConfig.class, mockCRestConfig); assertNotNull(actual); assertSame(mockCRestConfig, actual.crestConfig); }
public static <T> T instantiate(Class<T> clazz, CRestConfig crestConfig) throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException { try { return accessible(clazz.getDeclaredConstructor(CRestConfig.class)).newInstance(crestConfig); } catch (NoSuchMethodException e) { return accessible(clazz.getDeclaredConstructor()).newInstance(); } }
ComponentFactory { public static <T> T instantiate(Class<T> clazz, CRestConfig crestConfig) throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException { try { return accessible(clazz.getDeclaredConstructor(CRestConfig.class)).newInstance(crestConfig); } catch (NoSuchMethodException e) { return accessible(clazz.getDeclaredConstructor()).newInstance(); } } }
ComponentFactory { public static <T> T instantiate(Class<T> clazz, CRestConfig crestConfig) throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException { try { return accessible(clazz.getDeclaredConstructor(CRestConfig.class)).newInstance(crestConfig); } catch (NoSuchMethodException e) { return accessible(clazz.getDeclaredConstructor()).newInstance(); } } private  ComponentFactory(); }
ComponentFactory { public static <T> T instantiate(Class<T> clazz, CRestConfig crestConfig) throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException { try { return accessible(clazz.getDeclaredConstructor(CRestConfig.class)).newInstance(crestConfig); } catch (NoSuchMethodException e) { return accessible(clazz.getDeclaredConstructor()).newInstance(); } } private  ComponentFactory(); static T instantiate(Class<T> clazz, CRestConfig crestConfig); }
ComponentFactory { public static <T> T instantiate(Class<T> clazz, CRestConfig crestConfig) throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException { try { return accessible(clazz.getDeclaredConstructor(CRestConfig.class)).newInstance(crestConfig); } catch (NoSuchMethodException e) { return accessible(clazz.getDeclaredConstructor()).newInstance(); } } private  ComponentFactory(); static T instantiate(Class<T> clazz, CRestConfig crestConfig);  }