public static <T> T instantiateClassDefConstructor(Class<T> clazz) {
        //if constructor present then it should have a no arg constructor
        //if not present then default constructor is already their
        Objects.requireNonNull(clazz, "class to instantiate should not be null");
        if (clazz.getConstructors().length > 0
            && Arrays.stream(clazz.getConstructors()).noneMatch(c -> c.getParameterCount() == 0)) {
            throw new InstantiationException(
                "Default constructor is required to create instance of public class: " + clazz
                    .getName());
        }
        try {
            return clazz.getConstructor().newInstance();
        } catch (Exception e) {
            throw new InstantiationException(INSTANTIATION_ERROR_PREFIX + clazz.getName(), e);
        }
    }
@Test
    public void shouldFailToInstantiateNoDefaultConstructor() {
        assertThatThrownBy(
            () -> ClassUtils.instantiateClassDefConstructor(NoDefaultConstructor.class))
            .isInstanceOf(InstantiationException.class);
    }