From 86a6d12dd370ebd205f1dccf55486d73f73261ec Mon Sep 17 00:00:00 2001 From: He-Pin Date: Tue, 21 May 2024 21:27:40 +0800 Subject: [PATCH] chore: Add since 1.1.0 for `foldWhile` operator --- .../src/main/scala/org/apache/pekko/stream/javadsl/Flow.scala | 2 ++ .../src/main/scala/org/apache/pekko/stream/javadsl/Sink.scala | 2 ++ .../main/scala/org/apache/pekko/stream/javadsl/SubFlow.scala | 2 ++ .../src/main/scala/org/apache/pekko/stream/scaladsl/Flow.scala | 2 ++ .../src/main/scala/org/apache/pekko/stream/scaladsl/Sink.scala | 2 ++ 5 files changed, 10 insertions(+) diff --git a/stream/src/main/scala/org/apache/pekko/stream/javadsl/Flow.scala b/stream/src/main/scala/org/apache/pekko/stream/javadsl/Flow.scala index fc4ea3e3b36..856a2636168 100755 --- a/stream/src/main/scala/org/apache/pekko/stream/javadsl/Flow.scala +++ b/stream/src/main/scala/org/apache/pekko/stream/javadsl/Flow.scala @@ -1437,6 +1437,8 @@ final class Flow[In, Out, Mat](delegate: scaladsl.Flow[In, Out, Mat]) extends Gr * '''Cancels when''' downstream cancels * * See also [[FlowOps.fold]] + * + * @since 1.1.0 */ def foldWhile[T](zero: T, p: function.Predicate[T], f: function.Function2[T, Out, T]): javadsl.Flow[In, T, Mat] = new Flow(delegate.foldWhile(zero)(p.test)(f.apply)) diff --git a/stream/src/main/scala/org/apache/pekko/stream/javadsl/Sink.scala b/stream/src/main/scala/org/apache/pekko/stream/javadsl/Sink.scala index 0805e5df74c..a2f24df9dd0 100644 --- a/stream/src/main/scala/org/apache/pekko/stream/javadsl/Sink.scala +++ b/stream/src/main/scala/org/apache/pekko/stream/javadsl/Sink.scala @@ -57,6 +57,8 @@ object Sink { * The returned [[java.util.concurrent.CompletionStage]] will be completed with value of the final * function evaluation when the input stream ends, predicate `p` returns false, or completed with `Failure` * if there is a failure is signaled in the stream. + * + * @since 1.1.0 */ def foldWhile[U, In]( zero: U, p: function.Predicate[U], f: function.Function2[U, In, U]): javadsl.Sink[In, CompletionStage[U]] = diff --git a/stream/src/main/scala/org/apache/pekko/stream/javadsl/SubFlow.scala b/stream/src/main/scala/org/apache/pekko/stream/javadsl/SubFlow.scala index ea339fc70fe..5fb6bbfdcd0 100755 --- a/stream/src/main/scala/org/apache/pekko/stream/javadsl/SubFlow.scala +++ b/stream/src/main/scala/org/apache/pekko/stream/javadsl/SubFlow.scala @@ -817,6 +817,8 @@ class SubFlow[In, Out, Mat]( * '''Cancels when''' downstream cancels * * See also [[FlowOps.fold]] + * + * @since 1.1.0 */ def foldWhile[T](zero: T, p: function.Predicate[T], f: function.Function2[T, Out, T]): SubFlow[In, T, Mat] = new SubFlow(delegate.foldWhile(zero)(p.test)(f.apply)) diff --git a/stream/src/main/scala/org/apache/pekko/stream/scaladsl/Flow.scala b/stream/src/main/scala/org/apache/pekko/stream/scaladsl/Flow.scala index 8d22f29eb97..07ba28c9bfe 100755 --- a/stream/src/main/scala/org/apache/pekko/stream/scaladsl/Flow.scala +++ b/stream/src/main/scala/org/apache/pekko/stream/scaladsl/Flow.scala @@ -1844,6 +1844,8 @@ trait FlowOps[+Out, +Mat] { * '''Cancels when''' downstream cancels * * See also [[FlowOps.fold]] + * + * @since 1.1.0 */ def foldWhile[T](zero: T)(p: T => Boolean)(f: (T, Out) => T): Repr[T] = via( Fold[Out, T](zero, p, f).withAttributes(DefaultAttributes.foldWhile)) diff --git a/stream/src/main/scala/org/apache/pekko/stream/scaladsl/Sink.scala b/stream/src/main/scala/org/apache/pekko/stream/scaladsl/Sink.scala index 841685e7951..c487fbdaeee 100644 --- a/stream/src/main/scala/org/apache/pekko/stream/scaladsl/Sink.scala +++ b/stream/src/main/scala/org/apache/pekko/stream/scaladsl/Sink.scala @@ -424,6 +424,8 @@ object Sink { * if there is a failure signaled in the stream. * * @see [[#fold]] + * + * @since 1.1.0 */ def foldWhile[U, T](zero: U)(p: U => Boolean)(f: (U, T) => U): Sink[T, Future[U]] = Flow[T].foldWhile(zero)(p)(f).toMat(Sink.head)(Keep.right).named("foldWhileSink")