code: protected <T extends Listener> Collection<T> copyList(Class<T> listenerClass,
              Stream<Object> listeners, int sizeHint) {
          if (sizeHint == 0) {
              return Collections.emptyList();
          }
          return listeners
                  .map(listenerClass::cast)
                  .collect(Collectors.toCollection(() -> new ArrayList<>(sizeHint)));
      }
docs: Creates a collection from the given stream, casting each object to the
  provided listener class. The returned collection must not necessarily be
  mutable.
  
  @param <T> Type of the listeners in the given list.
  @param listenerClass The class of the objects in the provided list.
  @param listeners The stream to obtain the listeners for the resulting
  collection from.
  @param sizeHint Expected size of the input stream.
  @return A typed copy of the list.