MetaType[] typeParms = toType.getParameterizedType().getTypeParameters();
if (typeParms != null && typeParms.length == typeParamsSize) {
MetaClass typeParameter = null;
if (typeParms[typeParamIndex] instanceof MetaParameterizedType) {
MetaParameterizedType parameterizedTypeParemeter = (MetaParameterizedType) typeParms[typeParamIndex];
typeParameter = (MetaClass) parameterizedTypeParemeter.getRawType();
}
else if (typeParms[typeParamIndex] instanceof MetaClass) {
typeParameter = (MetaClass) typeParms[typeParamIndex];
}