+ 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

@ -28,6 +28,7 @@ import java.util.concurrent.CompletableFuture
import akka.annotation.InternalApi
import scala.compat.java8.FutureConverters._
import scala.reflect.ClassTag
/** Java API */
object Source {
@ -1284,6 +1285,24 @@ final class Source[+Out, +Mat](delegate: scaladsl.Source[Out, Mat]) extends Grap
def collect[T](pf: PartialFunction[Out, T]): javadsl.Source[T, Mat] =
new Source(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.Source[T, Mat] =
new Source(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.