private <T>Constructor<T> findFromStringConstructorByType(Class<T> cls){
  try {
    return cls.getDeclaredConstructor(String.class);
  }
 catch (  NoSuchMethodException ex) {
    try {
      return cls.getDeclaredConstructor(CharSequence.class);
    }
 catch (    NoSuchMethodException ex2) {
      throw new IllegalArgumentException("Constructor not found",ex2);
    }
  }
}

private < T > Constructor < T > findFromStringConstructorByType ( Class < T > cls ) { try { return cls . getDeclaredConstructor ( String . class ) ; } catch ( NoSuchMethodException ex ) { try { return cls . getDeclaredConstructor ( CharSequence . class ) ; } catch ( NoSuchMethodException ex2 ) { throw new IllegalArgumentException ( "Constructor not found" , ex2 ) ; } } }
finds the conversion method .
