package org.lima.parser.sstax.util;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public class GenericUtil {

	public static boolean isPrimitiveType(Class<?> type) {
		return (getPrimitiveValueOfStringMethod(type) != null)?true:false;
	}

	public static Method getPrimitiveValueOfStringMethod(Class<?> type) {
		Method m = null;
		try {
			m = type.getDeclaredMethod("valueOf", String.class);
			if(!Modifier.isStatic(m.getModifiers())) {
				m = null;
			}
		} catch (Exception e) {
			m = null;
		}
		return m;
	}
	
	public static Class<?>[] getActualTypes(Type genericType) {
        if (ParameterizedType.class.isAssignableFrom(genericType.getClass())) {
            ParameterizedType type = (ParameterizedType) genericType;
            return ((Class<?>[]) type.getActualTypeArguments());
        }
        return null;
    }
}

@@ -698,24 +698,18 @@
 ype) %7B%0D%0A
-        
+%09%09
 if (Para
@@ -773,28 +773,19 @@
 ())) %7B%0D%0A
-            
+%09%09%09
 Paramete
@@ -839,93 +839,271 @@
 e;%0D%0A
-            return ((Class%3C?%3E%5B%5D) type.getActualTypeArguments());%0D%0A        %7D%0D%0A        
+%09%09%09Type%5B%5D actualTypeArgs  = type.getActualTypeArguments();%0D%0A%09%09%09Class%3C?%3E%5B%5D actualTypes = new Class%3C?%3E%5BactualTypeArgs.length%5D;%0D%0A%09%09%09for(int i=0; i%3CactualTypeArgs.length; i++) %7B%0D%0A%09%09%09%09actualTypes%5Bi%5D = (Class%3C?%3E)actualTypeArgs%5Bi%5D;%0D%0A%09%09%09%7D%0D%0A%09%09%09return actualTypes;%0D%0A%09%09%7D%0D%0A%09%09
 retu
@@ -1116,12 +1116,9 @@
 l;%0D%0A
-    
+%09
 %7D%0D%0A%7D

fix bug