@SuppressWarnings("unchecked")
    public <T> TypeHandler<T> getInstance(Class<?> javaTypeClass, Class<?> typeHandlerClass) {
        if (javaTypeClass != null) {
          try {
            Constructor<?> c = typeHandlerClass.getConstructor(Class.class);
            return (TypeHandler<T>) c.newInstance(javaTypeClass);
          } catch (NoSuchMethodException ignored) {
            // ignored
          } catch (Exception e) {
            throw new TypeException("Failed invoking constructor for handler " + typeHandlerClass, e);
          }
        }
        try {
          Constructor<?> c = typeHandlerClass.getConstructor();
          return (TypeHandler<T>) c.newInstance();
        } catch (Exception e) {
          throw new TypeException("Unable to find a usable constructor for " + typeHandlerClass, e);
        }
      }
@ SuppressWarnings ( "unchecked" ) public < T > TypeHandler < T > getInstance ( Class < ? > javaTypeClass , Class < ? > typeHandlerClass ) { if ( javaTypeClass != null ) { try { Constructor < ? > c = typeHandlerClass . getConstructor ( Class . class ) ; return ( TypeHandler < T > ) c . newInstance ( javaTypeClass ) ; } catch ( NoSuchMethodException ignored ) { } catch ( Exception e ) { throw new TypeException ( "Failed invoking constructor for handler " + typeHandlerClass , e ) ; } } try { Constructor < ? > c = typeHandlerClass . getConstructor ( ) ; return ( TypeHandler < T > ) c . newInstance ( ) ; } catch ( Exception e ) { throw new TypeException ( "Unable to find a usable constructor for " + typeHandlerClass , e ) ; } }
实例化TypeHandler
@param javaTypeClass
@param typeHandlerClass
@return