code: public static Type extractTypeArgument(Type t, int index) throws InvalidTypesException {
  		if (t instanceof ParameterizedType) {
  			Type[] actualTypeArguments = ((ParameterizedType) t).getActualTypeArguments();
  
  			if (index < 0 || index >= actualTypeArguments.length) {
  				throw new InvalidTypesException("Cannot extract the type argument with index " +
  												index + " because the type has only " + actualTypeArguments.length +
  												" type arguments.");
  			} else {
  				return actualTypeArguments[index];
  			}
  		} else {
  			throw new InvalidTypesException("The given type " + t + " is not a parameterized type.");
  		}
  	}
docs: This method extracts the n-th type argument from the given type. An InvalidTypesException
  is thrown if the type does not have any type arguments or if the index exceeds the number
  of type arguments.
  
  @param t Type to extract the type arguments from
  @param index Index of the type argument to extract
  @return The extracted type argument
  @throws InvalidTypesException if the given type does not have any type arguments or if the
  index exceeds the number of type arguments.