@SuppressWarnings("unchecked")
    public static <T> T newInstance(Class<T> clazz) {
        Objects.requireNonNull(clazz);
        
        if (clazz.isInterface()) {
            return null;
        }
        
        try {
            Constructor<?> c = null;
            int n = clazz.getConstructors().length;
            if (n > 1) {
                Constructor<?> constuctors[] = Arrays.copyOf(clazz.getConstructors(), n);
                Arrays.sort(constuctors, new Comparator<Constructor<?>>() {
                    @Override
                    public int compare(Constructor<?> c1, Constructor<?> c2) {
                        int argList1 = c1.getGenericParameterTypes().length;
                        int argList2 = c2.getGenericParameterTypes().length;
                        return Integer.compare(argList1, argList2);
                    }
                });
                c = constuctors[0];
            } else if (n == 1) {
                c = clazz.getConstructors()[0];
            } else {
                c = clazz.getDeclaredConstructors()[0];
            }
            return (T) createWithConstructor(c);
        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException
                | InvocationTargetException e) {
            e.printStackTrace();
            return null;
        }
    }