(no commit message)
[utils] / support / general / src / main / java / org / wamblee / reflection / ReflectionUtils.java
index 7c5c45f94fd7f1e2d44a58fafbf38b7cd3f444f2..0da2d1f2ff31fb93e3518a031686b30aff34b239 100644 (file)
@@ -29,6 +29,20 @@ import java.util.Map;
  * @author Erik Brakkee
  */
 public class ReflectionUtils {
+    
+    public static final List<Class> PRIMITIVE_WRAPPERS =
+        createPrimitiveWrappers();
+    
+    private static final List<Class> createPrimitiveWrappers() { 
+        Class[] vals =   {
+            Boolean.class, Byte.class, Character.class, Short.class, Integer.class, Long.class,
+            Float.class, Double.class };
+        return Arrays.asList(vals);
+    }
+    
+  
+    
+    
     /**
      * Wraps a type by the corresponding wrapper type if it is a primitive type.
      * 
@@ -141,4 +155,16 @@ public class ReflectionUtils {
             getAllFields(superClass, aFound, aExcludedClasses);
         }
     }
+    
+    /**
+     * Checks if a class is a primitive type or wrapper type.
+     * @param aClass
+     * @return
+     */
+    public static boolean isPrimitive(Class aClass) { 
+        if ( aClass.isPrimitive()) { 
+            return true; 
+        }
+        return PRIMITIVE_WRAPPERS.contains(aClass);
+    }
 }