+ stream add collectType operator to Source,SubSource,Flow and SubFlow for javadsl.

add docs for collectType, do mirror it in scaladsl

mima
This commit is contained in:
虎鸣 2018-01-06 04:33:35 +08:00 committed by Konrad `ktoso` Malawski
parent 39c97c3306
commit e44fafd4b7
12 changed files with 204 additions and 15 deletions

View file

@ -19,6 +19,7 @@ import java.util.concurrent.CompletionStage
import akka.stream.impl.fusing.MapError
import scala.compat.java8.FutureConverters._
import scala.reflect.ClassTag
/**
* A stream of streams sub-flow of data elements, e.g. produced by `groupBy`.
@ -294,6 +295,24 @@ class SubSource[+Out, +Mat](delegate: scaladsl.SubFlow[Out, Mat, scaladsl.Source
def collect[T](pf: PartialFunction[Out, T]): SubSource[T, Mat] =
new SubSource(delegate.collect(pf))
/**
* Transform this stream by testing the type of each of the elements
* on which the element is an instance of the provided type as they pass through this processing step.
* Non-matching elements are filtered out.
*
* Adheres to the [[ActorAttributes.SupervisionStrategy]] attribute.
*
* '''Emits when''' the element is an instance of the provided type
*
* '''Backpressures when''' the element is an instance of the provided type and downstream backpressures
*
* '''Completes when''' upstream completes
*
* '''Cancels when''' downstream cancels
*/
def collectType[T](clazz: Class[T]): javadsl.SubSource[T, Mat] =
new SubSource(delegate.collectType[T](ClassTag[T](clazz)))
/**
* Chunk up this stream into groups of the given size, with the last group
* possibly smaller than requested due to end-of-stream.