enumType = ((Enumerated) annotation).value();
}
}
return new EnumParamMapper(paramName, idx, enumType);
}
return new ParamMapper(paramName, idx);
} if (paramType instanceof ParameterizedType) {
ParameterizedType pt = (ParameterizedType) paramType;
Type raw = pt.getRawType();
if (!(raw instanceof Class))
throw new IllegalArgumentException(String.format("Cannot map class %s for parameter %s of %s.%s", paramType, paramName, className, methodName));
Class<?> klass = (Class<?>)raw;
Class<?> firstTypeParam = ReflectionUtils.getParam(pt, 0, paramName);
if (List.class.isAssignableFrom(klass) && firstTypeParam.isAnnotationPresent(UDT.class)) {
UDTMapper<?> valueMapper = mappingManager.getUDTMapper(firstTypeParam);
return new UDTListParamMapper(paramName, idx, valueMapper);
}
if (Set.class.isAssignableFrom(klass) && firstTypeParam.isAnnotationPresent(UDT.class)) {
UDTMapper<?> valueMapper = mappingManager.getUDTMapper(firstTypeParam);
return new UDTSetParamMapper(paramName, idx, valueMapper);
}
if (Map.class.isAssignableFrom(klass)) {
Class<?> secondTypeParam = ReflectionUtils.getParam(pt, 1, paramName);
UDTMapper<?> keyMapper = firstTypeParam.isAnnotationPresent(UDT.class) ? mappingManager.getUDTMapper(firstTypeParam) : null;
UDTMapper<?> valueMapper = secondTypeParam.isAnnotationPresent(UDT.class) ? mappingManager.getUDTMapper(secondTypeParam) : null;
if (keyMapper != null || valueMapper != null) {
return new UDTMapParamMapper(paramName, idx, keyMapper, valueMapper);
}
}
return new ParamMapper(paramName, idx);
} else {
throw new IllegalArgumentException(String.format("Cannot map class %s for parameter %s of %s.%s", paramType, paramName, className, methodName));
}
}