private static Object [ ] toObjectArray ( Object primitiveArray ) { if ( primitiveArray == null ) { throw new NullPointerException ( ) ; } if ( primitiveArray instanceof Object [ ] ) { return ( Object [ ] ) primitiveArray ; } if ( primitiveArray instanceof Collection ) { return ( ( Collection ) primitiveArray ) . toArray ( ) ; } Class clazz = primitiveArray . getClass ( ) ; if ( ! clazz . isArray ( ) ) { return null ; } int length = Array . getLength ( primitiveArray ) ; Object [ ] array = new Object [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { array [ i ] = Array . get ( primitiveArray , i ) ; } return array ; }
Convert an array of primitives to an array of boxed objects .