List of utility methods to do Class New Instance
T | newInstance(Class> cls) new Instance Object instance; try { instance = cls.newInstance(); } catch (Exception e) { throw new RuntimeException(e); return (T) instance; |
Object | newInstance(Class> cls) new Instance try { return cls.newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); return null; ... |
T | newInstance(Class> cls, Map new Instance final Constructor ctor = getDefaultConstructor(cls, cache); try { return (T) ctor.newInstance(); } catch (Throwable t) { throw new RuntimeException("Failed to instantiate " + cls.getName(), t); |
Object | newInstance(Class> componentType, int... dimensions) new Instance return Array.newInstance(componentType, dimensions);
|
Object | newInstance(Class> entity) newInstance. if (entity == null) { return null; try { return entity.newInstance(); } catch (Exception e) { throw new RuntimeException(e); |
T | newInstance(Class> theClass, Class Create an object for the given class and initialize it from conf T result; try { if (!expected.isAssignableFrom(theClass)) { throw new Exception("Specified class " + theClass.getName() + "" + "does not extend/implement " + expected.getName()); Class<? extends T> clazz = (Class<? extends T>) theClass; Constructor<? extends T> meth = clazz.getDeclaredConstructor(EMPTY_ARRAY); ... |
I | newInstance(Class interfaceDefinition, String className, ClassLoader classLoader) new Instance try { Class<I> spiClass; if (classLoader == null) { spiClass = (Class<I>) Class.forName(className); } else { spiClass = (Class<I>) classLoader.loadClass(className); return spiClass.newInstance(); ... |
T | newInstance(Class new Instance try { return (T) aClass.getConstructor(typeArgs(args)).newInstance(args); } catch (Exception e) { throw new RuntimeException(e); |
T[] | newInstance(Class Create single element array of the specified class which contains the specified value T[] array = (T[]) Array.newInstance(arrayComponentClass, 1);
array[0] = value;
return array;
|
T | newInstance(Class new Instance T instance = null; try { instance = beanClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new IllegalArgumentException("create instance of " + beanClass.getSimpleName() + "failed. WTF?", e); return instance; ... |