@SuppressWarnings({ "unchecked", "all" })
  public static <T> Constructor<T> findConstructor(Class<T> type, Object... arguments) {

    for (Constructor<?> constructor : type.getDeclaredConstructors()) {

      Class<?>[] parameterTypes = constructor.getParameterTypes();

      if (ArrayUtils.nullSafeLength(arguments) == parameterTypes.length) {

        boolean match = true;

        for (int index = 0; match && index < parameterTypes.length; index++) {
          match &= instanceOf(arguments[index], parameterTypes[index]);
        }

        if (match) {
          return (Constructor<T>) constructor;
        }
      }
    }

    return null;
  }
@ SuppressWarnings ( { "unchecked" , "all" } ) public static < T > Constructor < T > findConstructor ( Class < T > type , Object ... arguments ) { for ( Constructor < ? > constructor : type . getDeclaredConstructors ( ) ) { Class < ? > [ ] parameterTypes = constructor . getParameterTypes ( ) ; if ( ArrayUtils . nullSafeLength ( arguments ) == parameterTypes . length ) { boolean match = true ; for ( int index = 0 ; match && index < parameterTypes . length ; index ++ ) { match &= instanceOf ( arguments [ index ] , parameterTypes [ index ] ) ; } if ( match ) { return ( Constructor < T > ) constructor ; } } } return null ; }
Attempts to find a compatible constructor on the given class type with a signature having parameter types
satisfying the specified arguments.

@param <T> the generic class type to search for the constructor.
@param type the Class type to search for the desired constructor.
@param arguments an array of Object arguments used to match the constructor's signature.
@return a Constructor from the given class type whose signature matches the specified arguments.
@see java.lang.Class
@see java.lang.Class#getDeclaredConstructors()
@see java.lang.reflect.Constructor