Class RxJavaInterop


  • public class RxJavaInterop
    extends java.lang.Object
    Static factory class that provides methods to obtain commonly used instances for interoperation between RxJava and standard JRE.
    Since:
    10.0
    Author:
    wburns
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <R> io.reactivex.functions.Function<? super java.lang.Throwable,​org.reactivestreams.Publisher<R>> cacheExceptionWrapper()  
      static io.reactivex.functions.Function<io.reactivex.Completable,​java.util.concurrent.CompletionStage<java.lang.Void>> completableToCompletionStage()  
      static java.util.function.Function<java.util.concurrent.CompletionStage<?>,​io.reactivex.Completable> completionStageToCompletable()  
      static io.reactivex.Completable completionStageToCompletable​(java.util.concurrent.CompletionStage<java.lang.Void> stage)  
      static <E> io.reactivex.Maybe<E> completionStageToMaybe​(java.util.concurrent.CompletionStage<E> stage)  
      static <E> io.reactivex.Single<E> completionStageToSingle​(java.util.concurrent.CompletionStage<E> stage)  
      static <K,​V>
      io.reactivex.functions.Function<java.util.Map.Entry<K,​V>,​K>
      entryToKeyFunction()
      Provides a Function that can be used to convert from an instance of Map.Entry to the key of the entry.
      static <E> io.reactivex.functions.Function<io.reactivex.Flowable<E>,​java.util.concurrent.CompletionStage<java.lang.Void>> flowableToCompletionStage()
      Provides an interop function that can be used to convert a Flowable into a CompletionStage.
      static <E> io.reactivex.Flowable<E> fromStream​(java.util.stream.Stream<E> stream)
      Transforms a Stream to a Flowable.
      static <E> io.reactivex.functions.Function<io.reactivex.Maybe<E>,​java.util.concurrent.CompletionStage<E>> maybeToCompletionStage()
      Provides an interop function that can be used to convert a Maybe into a CompletionStage.
      static <E> io.reactivex.functions.Function<io.reactivex.Single<? extends E>,​java.util.concurrent.CompletionStage<E>> singleToCompletionStage()
      Provides an interop function that can be used to convert a Single into a CompletionStage.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • completableToCompletionStage

        public static io.reactivex.functions.Function<io.reactivex.Completable,​java.util.concurrent.CompletionStage<java.lang.Void>> completableToCompletionStage()
      • singleToCompletionStage

        public static <E> io.reactivex.functions.Function<io.reactivex.Single<? extends E>,​java.util.concurrent.CompletionStage<E>> singleToCompletionStage()
        Provides an interop function that can be used to convert a Single into a CompletionStage. Note that this function is not from the standard java.util.function package, but rather Function to interop better with the Single.to(Function) method.
        Type Parameters:
        E - underlying type
        Returns:
        rxjava function to convert Single to CompletionStage
      • maybeToCompletionStage

        public static <E> io.reactivex.functions.Function<io.reactivex.Maybe<E>,​java.util.concurrent.CompletionStage<E>> maybeToCompletionStage()
        Provides an interop function that can be used to convert a Maybe into a CompletionStage. Note that this function is not from the standard java.util.function package, but rather Function to interop better with the Maybe.to(Function) method.
        Type Parameters:
        E - underlying type
        Returns:
        rxjava function to convert Maybe to CompletionStage
      • flowableToCompletionStage

        public static <E> io.reactivex.functions.Function<io.reactivex.Flowable<E>,​java.util.concurrent.CompletionStage<java.lang.Void>> flowableToCompletionStage()
        Provides an interop function that can be used to convert a Flowable into a CompletionStage. Note that this function is not from the standard java.util.function package, but rather Function to interop better with the Maybe.to(Function) method. Any published values are ignored and the returned CompletionStage is completed when the Flowable completes or completed exceptionally if the Flowable has an error.
        Returns:
        rxjava function to convert Flowable to CompletionStage
      • completionStageToCompletable

        public static io.reactivex.Completable completionStageToCompletable​(java.util.concurrent.CompletionStage<java.lang.Void> stage)
      • completionStageToCompletable

        public static java.util.function.Function<java.util.concurrent.CompletionStage<?>,​io.reactivex.Completable> completionStageToCompletable()
      • completionStageToSingle

        public static <E> io.reactivex.Single<E> completionStageToSingle​(java.util.concurrent.CompletionStage<E> stage)
      • completionStageToMaybe

        public static <E> io.reactivex.Maybe<E> completionStageToMaybe​(java.util.concurrent.CompletionStage<E> stage)
      • fromStream

        public static <E> io.reactivex.Flowable<E> fromStream​(java.util.stream.Stream<E> stream)
        Transforms a Stream to a Flowable. Note that the resulting Flowable can only be subscribed to once as a Stream only allows a single terminal operation performed upon it. When the Flowable is completed, either exceptionally or normally, the Stream is also closed
        Type Parameters:
        E - inner type
        Parameters:
        stream - the stream to transform to a Flowable
        Returns:
        Flowable that can only be subscribed to once
      • entryToKeyFunction

        public static <K,​V> io.reactivex.functions.Function<java.util.Map.Entry<K,​V>,​K> entryToKeyFunction()
        Provides a Function that can be used to convert from an instance of Map.Entry to the key of the entry. This is useful for the instance passed to a method like Flowable.map(Function).
        Type Parameters:
        K - key type
        V - value type
        Returns:
        rxjava function to convert from a Map.Entry to its key.
      • cacheExceptionWrapper

        public static <R> io.reactivex.functions.Function<? super java.lang.Throwable,​org.reactivestreams.Publisher<R>> cacheExceptionWrapper()