public static <T> T[] toArray(Class<T> componentType, Collection<T> collection) {
        T[] array = (T[]) Array.newInstance(componentType, collection.size());

        if (componentType.isAssignableFrom(Typ.getComponentType(collection))) {
            return collection.toArray(array);
        } else {

            int index = 0;
            for (Object o : collection) {
                array[index] = Conversions.coerce(componentType, o);
                index++;
            }
            return array;
        }
    }
public static < T > T [ ] toArray ( Class < T > componentType , Collection < T > collection ) { T [ ] array = ( T [ ] ) Array . newInstance ( componentType , collection . size ( ) ) ; if ( componentType . isAssignableFrom ( Typ . getComponentType ( collection ) ) ) { return collection . toArray ( array ) ; } else { int index = 0 ; for ( Object o : collection ) { array [ index ] = Conversions . coerce ( componentType , o ) ; index ++ ; } return array ; } }
}