code: protected static <T> Class[] findTypes(Collection<T> c) {
      Set<Class> types = new HashSet<>();
      types.add(JAXBCollection.class);
      for (T o : c) {
        if (o != null) {
          types.add(o.getClass());
        }
      }
      return types.toArray(new Class[0]);
    }
docs: Discovers all the classes in the given Collection. These need to be in the JAXBContext if you
  want to marshal those objects. Unfortunatly there's no way of getting the generic type at
  runtime.
  
  @param c Collection that needs to be scanned
  @return Classes found in the collection, including JAXBCollection.