@ SuppressWarnings ( "PMD.LooseCoupling" ) public static Object convertToArray ( final Object result , final Class entityType , final boolean projection ) { final Collection res = result instanceof Collection // no projection because its applied later ? ( Collection ) result : convertToCollectionImpl ( result , ArrayList . class , entityType , false ) ; final Object array = Array . newInstance ( entityType , res . size ( ) ) ; int i = 0 ; for ( Object obj : res ) { Array . set ( array , i ++ , projection ? applyProjection ( obj , entityType ) : obj ) ; } return array ; }
Convert result object to array .