shillelagh/src/main/java/shillelagh/internal/ShillelaghUtil.java
@SuppressWarnings("unchecked")
  public static <T> T createInstance(Class<T> clazz) {
    if (clazz.isInterface()) {
      if (clazz == List.class) {
        return (T) new ArrayList();
      } else if (clazz == Map.class) {
        return (T) new HashMap();
      }

      throw new UnsupportedOperationException("Interface types can not be instantiated.");
    }

    ObjectInstantiator instantiator = OBJENESIS.getInstantiatorOf(clazz);
    return (T) instantiator.newInstance();
  }
@SuppressWarnings("unchecked")
  public static <T> T createInstance(Class<T> clazz) {
    if (clazz.isInterface()) {
      if (clazz == List.class) {
        return (T) new ArrayList();
      } else if (clazz == Map.class) {
        return (T) new HashMap();
      }

      throw new UnsupportedOperationException("Interface types can not be instantiated.");
    }

    ObjectInstantiator instantiator = OBJENESIS.getInstantiatorOf(clazz);
    return (T) instantiator.newInstance();
  }
@ SuppressWarnings ( "unchecked" ) public static < T > T createInstance ( Class < T > clazz ) { if ( clazz . isInterface ( ) ) { if ( clazz == List . class ) { return ( T ) new ArrayList ( ) ; } else if ( clazz == Map . class ) { return ( T ) new HashMap ( ) ; } throw new UnsupportedOperationException ( "Interface types can not be instantiated." ) ; } ObjectInstantiator instantiator = OBJENESIS . getInstantiatorOf ( clazz ) ; return ( T ) instantiator . newInstance ( ) ; }
Takes a class type and constructs it. If the class does not have an empty constructor this
will
find the parametrized constructor and use nulls and default values to construct the class.

@param clazz The class to construct.
@param <T> The type of the class to construct.
@return The constructed object.
Takes a class type and constructs it . If the class does not have an empty constructor this will find the parametrized constructor and use nulls and default values to construct the class .