class ReflectionUtils {

    @Api(2.0)
    @Nullable
    public static <T> T newInstance(@NonNull Class<T> clazz) {
        try {
            Constructor<T> constructor = clazz.getDeclaredConstructor();
            if (constructor != null) {
                constructor.setAccessible(true);
                return constructor.newInstance();
            }
            return null;
        } catch (InstantiationException e) {
            throw new HaloReflectionException("The instance for " + clazz.getCanonicalName() + " can not be created.", e);
        } catch (IllegalAccessException e) {
            throw new HaloReflectionException("The default constructor of " + clazz.getCanonicalName() + " is not visible to create the instance.", e);
        } catch (NoSuchMethodException e) {
            throw new HaloReflectionException("No default constructor found for " + clazz.getCanonicalName() + ".", e);
        } catch (InvocationTargetException e) {
            throw new HaloReflectionException("The default constructor could not be invoked on " + clazz.getCanonicalName() + ".", e);
        }
    }

    private  ReflectionUtils();

}