@SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testCreateObject_RTE() { Class c = String.class; try { OASFactory.createObject(c); Assert.fail("Expected a runtime error."); } catch (RuntimeException e) { Assert.assertEquals("SROAP09000: Class 'java.lang.String' is not Constructible.", e.getMessage()); } }
@SuppressWarnings("unchecked") @Override public <T extends Constructible> T createObject(Class<T> clazz) { if (clazz == null) { throw new NullPointerException(); } Class<? extends Constructible> implClass = registry.get(clazz); if (implClass == null) { throw SpiMessages.msg.classNotConstructible(clazz.getName()); } try { return (T) implClass.getConstructor().newInstance(); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { throw new IllegalArgumentException(e); } }
OASFactoryResolverImpl extends OASFactoryResolver { @SuppressWarnings("unchecked") @Override public <T extends Constructible> T createObject(Class<T> clazz) { if (clazz == null) { throw new NullPointerException(); } Class<? extends Constructible> implClass = registry.get(clazz); if (implClass == null) { throw SpiMessages.msg.classNotConstructible(clazz.getName()); } try { return (T) implClass.getConstructor().newInstance(); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { throw new IllegalArgumentException(e); } } }
OASFactoryResolverImpl extends OASFactoryResolver { @SuppressWarnings("unchecked") @Override public <T extends Constructible> T createObject(Class<T> clazz) { if (clazz == null) { throw new NullPointerException(); } Class<? extends Constructible> implClass = registry.get(clazz); if (implClass == null) { throw SpiMessages.msg.classNotConstructible(clazz.getName()); } try { return (T) implClass.getConstructor().newInstance(); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { throw new IllegalArgumentException(e); } }  }
OASFactoryResolverImpl extends OASFactoryResolver { @SuppressWarnings("unchecked") @Override public <T extends Constructible> T createObject(Class<T> clazz) { if (clazz == null) { throw new NullPointerException(); } Class<? extends Constructible> implClass = registry.get(clazz); if (implClass == null) { throw SpiMessages.msg.classNotConstructible(clazz.getName()); } try { return (T) implClass.getConstructor().newInstance(); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { throw new IllegalArgumentException(e); } }  @SuppressWarnings("unchecked") @Override T createObject(Class<T> clazz); }
OASFactoryResolverImpl extends OASFactoryResolver { @SuppressWarnings("unchecked") @Override public <T extends Constructible> T createObject(Class<T> clazz) { if (clazz == null) { throw new NullPointerException(); } Class<? extends Constructible> implClass = registry.get(clazz); if (implClass == null) { throw SpiMessages.msg.classNotConstructible(clazz.getName()); } try { return (T) implClass.getConstructor().newInstance(); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { throw new IllegalArgumentException(e); } }  @SuppressWarnings("unchecked") @Override T createObject(Class<T> clazz);  }