public static <A> A[] asArray(Collection<A> aCol, Class<A> clazz) {
        A[] as = (A[]) Array.newInstance(clazz, aCol.size());
        int i = 0;
        for (A a : aCol) {
            as[i++] = a;
        }
        return as;
    }