/** * Adapt a {@code Sink<Long> to an {@code LongConsumer}, ideally simply * by casting. */ private static LongConsumer adapt(Sink<Long> sink) { if (sink instanceof LongConsumer) { return (LongConsumer) sink; } else { if (Tripwire.ENABLED) Tripwire.trip(AbstractPipeline.class, "using LongStream.adapt(Sink<Long> s)"); return sink::accept; } }
/** * Adapt a {@code Sink<Integer> to an {@code IntConsumer}, ideally simply * by casting. */ private static IntConsumer adapt(Sink<Integer> sink) { if (sink instanceof IntConsumer) { return (IntConsumer) sink; } else { if (Tripwire.ENABLED) Tripwire.trip(AbstractPipeline.class, "using IntStream.adapt(Sink<Integer> s)"); return sink::accept; } }
/** * Adapt a {@code Spliterator<Long>} to a {@code Spliterator.OfLong}. * * @implNote The implementation attempts to cast to a Spliterator.OfLong, and throws an exception * if this cast is not possible. */ private static Spliterator.OfLong adapt(Spliterator<Long> s) { if (s instanceof Spliterator.OfLong) { return (Spliterator.OfLong) s; } else { if (Tripwire.ENABLED) Tripwire.trip(AbstractPipeline.class, "using LongStream.adapt(Spliterator<Long> s)"); throw new UnsupportedOperationException("LongStream.adapt(Spliterator<Long> s)"); } }
/** * Adapt a {@code Spliterator<Integer>} to a {@code Spliterator.OfInt}. * * @implNote The implementation attempts to cast to a Spliterator.OfInt, and throws an exception * if this cast is not possible. */ private static Spliterator.OfInt adapt(Spliterator<Integer> s) { if (s instanceof Spliterator.OfInt) { return (Spliterator.OfInt) s; } else { if (Tripwire.ENABLED) Tripwire.trip(AbstractPipeline.class, "using IntStream.adapt(Spliterator<Integer> s)"); throw new UnsupportedOperationException("IntStream.adapt(Spliterator<Integer> s)"); } }