Obtain the {@link StreamCut} pointing to the current HEAD of the Stream.
@param stream The Stream.
@return {@link StreamCut} pointing to the HEAD of the Stream.
15575
public CompletableFuture<StreamCut> fetchHeadStreamCut(final Stream stream) {
        //Fetch segments pointing to the current HEAD of the stream.
        return controller.getSegmentsAtTime(new StreamImpl(stream.getScope(), stream.getStreamName()), 0L)
                         .thenApply( s -> new StreamCutImpl(stream, s));
    }
597273
public StreamCutReferenceRecord findStreamCutReferenceForTime(long time) {
        int beforeIndex = getGreatestLowerBound(this, time, StreamCutReferenceRecord::getRecordingTime);
        if (beforeIndex < 0) {
            return null;
        }

        return retentionRecords.get(beforeIndex);
    }
481584
public static <U> Stream<U> takeUntil(final Stream<U> stream, final Predicate<? super U> predicate) {
        return takeWhile(stream, predicate.negate());

    }
506995
public static <T> Set<T> toSet(Stream<T> stream) {
        return stream.collect(Collectors.<T>toSet());
    }
170856
public <T, R> Stream<R> map(Stream<T> stream, Function<? super T, ? extends R> mapper) {
        Callable<Stream<R>> callable = () -> stream.map(mapper);
        return ThreadMethods.forkJoinExecution(callable, concurrencyConfiguration, stream.isParallel());
    }
17038
public static final <A> Collection<A> toConcurrentLazyCollection(final Stream<A> stream) {
        return toConcurrentLazyCollection(stream.iterator());
    }
268952
@Override
    public StreamByteInput<T> source(final T source) {
        return (StreamByteInput<T>) super.source(source);
    }
791586
public static StreamUtil getInstance() {

    if (instance == null) {
      synchronized (StreamUtilImpl.class) {
        if (instance == null) {
          StreamUtilImpl util = new StreamUtilImpl();
          util.initialize();
          instance = util;
        }
      }
    }
    return instance;
  }
617095
public static LineString of(Stream<Point> points) {
        return of(points.collect(Collectors.toList()));
    }
1362768
public static Controller.StreamCut decode(final String scope, final String stream, Map<Long, Long> streamCut) {
        return Controller.StreamCut.newBuilder().setStreamInfo(createStreamInfo(scope, stream)).putAllCut(streamCut).build();
    }
301873
public Stream<FlatTreeNode<T>> stream() {
		return IntStream.range(0, _nodes.size()).mapToObj(this::nodeAt);
	}
320281
public static <T, U> Stream<U> cast(final Stream<T> stream, final Class<? extends U> type) {
        return stream.map(type::cast);
    }
166614
public static <T> Iterable<Indexed<T>> enumerate(Iterable<T> stream) {
        return new Iterable<Indexed<T>>() {

            @Override
            public Iterator<Indexed<T>> iterator() {
                Iterator<T> itr = stream.iterator();
                return new Iterator<Indexed<T>>() {

                    private int i = 0;

                    @Override
                    public boolean hasNext() {
                        return itr.hasNext();
                    }

                    @Override
                    public Indexed<T> next() {
                        Indexed<T> nextPair = new Indexed<T>(itr.next(), i);
                        i++;
                        return nextPair;
                    }
                };
            }
        };
    }
1351984
private void closeStream(InputStream stream) {

        if (stream != null) {
            try {
                stream.close();
            } catch (Exception ex) {
                LOG.error(ex.getLocalizedMessage(), ex);
            }
        }
    }
495698
public static <U> Stream<U> takeWhile(final Stream<U> stream, final Predicate<? super U> predicate) {
        return StreamSupport.stream(new LimitWhileSpliterator<>(stream.spliterator(), predicate),stream.isParallel());
    }
1061550
public static Map<HeaderName<?>, Object> copyFromStream(@Nullable final Stream<Map.Entry<HeaderName<?>, Object>> stream) {
        Map<HeaderName<?>, Object> headerMap;

        if (stream == null) {
            headerMap = new HashMap<>();
        } else {
            headerMap = stream.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
        }

        return headerMap;
    }
891255
@SuppressWarnings("rawtypes")
    public Stream<Link> stream() {
        return links.values()
                .stream()
                .map(obj -> {
                    if (obj instanceof List) {
                        return (List) obj;
                    } else {
                        return singletonList(obj);
                    }
                })
                .flatMap(Collection::stream);
    }