@SuppressWarnings({ "hiding", "unchecked" })
        public <T> T[] toArray(T[] a) {
            final Class<?> componentType = a.getClass().getComponentType();
            T[] out = (T[]) java.lang.reflect.Array.newInstance(componentType, myvalues.size());

            Arrays.setAll(out, (i) -> (T) createFieldValue(myvalues.get(i)));
            return out;
        }
This wrapper class is used to wrap a list that isn't a list of field
values. This is done, as to not alter behaviour from previous state,
where people could add whatever list to a document, and then keep adding
stuff to the list afterwards.

<p>
TODO: Remove this class and only allow instance of Array to be added.
document/src/main/java/com/yahoo/document/datatypes/Array.java