public static Class < ? > getPrimitiveType ( Class < ? > javaType ) { if ( javaType == Integer . class ) return int . class ; if ( javaType == Short . class ) return short . class ; if ( javaType == Boolean . class ) return boolean . class ; if ( javaType == Byte . class ) return byte . class ; if ( javaType == Long . class ) return long . class ; if ( javaType == Double . class ) return double . class ; if ( javaType == Float . class ) return float . class ; if ( javaType == Character . class ) return char . class ; if ( javaType == Integer [ ] . class ) return int [ ] . class ; if ( javaType == Short [ ] . class ) return short [ ] . class ; if ( javaType == Boolean [ ] . class ) return boolean [ ] . class ; if ( javaType == Byte [ ] . class ) return byte [ ] . class ; if ( javaType == Long [ ] . class ) return long [ ] . class ; if ( javaType == Double [ ] . class ) return double [ ] . class ; if ( javaType == Float [ ] . class ) return float [ ] . class ; if ( javaType == Character [ ] . class ) return char [ ] . class ; if ( javaType . isArray ( ) && javaType . getComponentType ( ) . isArray ( ) ) { Class < ? > compType = getPrimitiveType ( javaType . getComponentType ( ) ) ; return Array . newInstance ( compType , 0 ) . getClass ( ) ; } return javaType ; }
Get the corresponding primitive for a give wrapper type . Also handles arrays of which .