code: public static <E> void marshallCollection(Collection<E> collection, ObjectOutput out, ElementWriter<E> writer) throws IOException {
        final int size = collection == null ? NULL_VALUE : collection.size();
        marshallSize(out, size);
        if (size <= 0) {
           return;
        }
        for (E e : collection) {
           writer.writeTo(out, e);
        }
     }
docs: Marshall a {@link Collection}.
  <p>
  This method supports {@code null} {@code collection}.
  
  @param collection {@link Collection} to marshal.
  @param out        {@link ObjectOutput} to write.
  @param writer     {@link ElementWriter} that writes single element to the output.
  @param <E>        Collection's element type.
  @throws IOException If any of the usual Input/Output related exceptions occur.