code: public static <E> Collection<E> createLazyCollectionFromStream(Supplier<Stream<E>> sequentialStreamSupplier, int size)
    {
      return new AbstractCollection<E>()
      {
        @Override
        public Iterator<E> iterator()
        {
          return sequentialStreamSupplier.get().iterator();
        }
  
        @Override
        public Spliterator<E> spliterator()
        {
          return sequentialStreamSupplier.get().spliterator();
        }
  
        @Override
        public Stream<E> stream()
        {
          return sequentialStreamSupplier.get();
        }
  
        @Override
        public Stream<E> parallelStream()
        {
          return sequentialStreamSupplier.get().parallel();
        }
  
        @Override
        public int size()
        {
          return size;
        }
      };
    }
docs: Returns a lazy collection from a stream supplier and a size. {@link Collection#iterator()} of the returned
  collection delegates to {@link Stream#iterator()} on the stream returned from the supplier.