if (genericType instanceof ParameterizedType)
{
ParameterizedType paramtype = (ParameterizedType)genericType;
if (paramtype.getActualTypeArguments().length == 1)
{
Type argType = paramtype.getActualTypeArguments()[0];
if (argType instanceof Class)
{
return (Class) argType;
}
else if (argType instanceof ParameterizedType)
{
return (Class) ((ParameterizedType)argType).getRawType();
}
else if (argType instanceof GenericArrayType)
{
// Create array of zero length to get class of array type (is there a better way?)
Type cmptType = ((GenericArrayType)argType).getGenericComponentType();
return Array.newInstance((Class)cmptType, 0).getClass();
}
else
{
throw new NucleusUserException("Unsupported generic type: " + argType);