Module life.expert

Class Patterns


  • public final class Patterns
    extends java.lang.Object
     auxiliary static functions with arguments - several Mono
    
          1) Gently convert Vavr's Try to Reactor's Flux
                  monoFromNullableTry
                  monoFromTry
                  fluxFromNullableTry
                  fluxFromTry
    
          2) Range of Integers from start to end, even in reverse order.
                 range( final int start , final int end )
                 longRange( final long start , final long end )
    
          3) Indexed (with Integer or Long) elements of Flux. Wrap element with index into Tuple2
                  indexed
                  longIndexed
    
     
    • Constructor Summary

      Constructors 
      Constructor Description
      Patterns()  
    • Method Summary

      Modifier and Type Method Description
      static <T> reactor.core.publisher.Flux<T> fluxFromNullableTry​(io.vavr.control.Try<T> tryObject)
      Flux from try.
      static <T> reactor.core.publisher.Flux<T> fluxFromTry​(io.vavr.control.Try<T> tryObject)
      Flux from try.
      static <T,​R>
      java.util.function.Function<T,​reactor.core.publisher.Mono<R>>
      functionToMonoParallel​(io.vavr.CheckedFunction1<T,​R> function, reactor.core.scheduler.Scheduler scheduler)
      Alias for CheckedConsumer.unchecked()
      static <T,​R>
      java.util.function.Function<T,​reactor.core.publisher.Mono<R>>
      functionToMonoParallelLogError​(io.vavr.CheckedFunction1<T,​R> function, reactor.core.scheduler.Scheduler scheduler, java.lang.String message)
      Function to mono parallel log error function.
      static <E> reactor.core.publisher.Flux<io.vavr.Tuple2<java.lang.Integer,​E>> indexed​(reactor.core.publisher.Flux<E> flux)
      Indexed (with Integer) elements of Flux.
      static <E> reactor.core.publisher.Flux<io.vavr.Tuple2<java.lang.Long,​E>> longIndexed​(reactor.core.publisher.Flux<E> flux)
      Indexed (with Long) elements of Flux.
      static reactor.core.publisher.Flux<java.lang.Long> longRange​(long start, long end)
      Range of Longs from start to end, even in reverse order.
      static <T> reactor.core.publisher.Mono<T> monoFromNullableTry​(io.vavr.control.Try<T> tryObject)
      Mono from try.
      static <T> reactor.core.publisher.Mono<T> monoFromTry​(io.vavr.control.Try<T> tryObject)
      Mono from try.
      static reactor.core.publisher.Flux<java.lang.Integer> range​(int start, int end)
      Range of Integers from start to end, even in reverse order.
      static <T> io.vavr.control.Try<T> tryFromFlux​(reactor.core.publisher.Flux<T> flux)
      Try from Flux.
      static <T> io.vavr.control.Try<T> tryFromMono​(reactor.core.publisher.Mono<T> mono)
      Try from Mono.
      • Methods inherited from class java.lang.Object

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

      • Patterns

        public Patterns()
    • Method Detail

      • monoFromNullableTry

        public static <T> reactor.core.publisher.Mono<T> monoFromNullableTry​(io.vavr.control.Try<T> tryObject)
        Mono from try. Try with null inside transforms to empty event
        Type Parameters:
        T - the type parameter
        Parameters:
        tryObject - the try object
        Returns:
        the mono
      • monoFromTry

        public static <T> reactor.core.publisher.Mono<T> monoFromTry​(io.vavr.control.Try<T> tryObject)
        Mono from try. Try with null inside transforms to error event
        Type Parameters:
        T - the type parameter
        Parameters:
        tryObject - the try object
        Returns:
        the mono
      • fluxFromNullableTry

        public static <T> reactor.core.publisher.Flux<T> fluxFromNullableTry​(io.vavr.control.Try<T> tryObject)
        Flux from try. Try with null inside transforms to empty event
        Type Parameters:
        T - the type parameter
        Parameters:
        tryObject - the try object
        Returns:
        the flux
      • fluxFromTry

        public static <T> reactor.core.publisher.Flux<T> fluxFromTry​(io.vavr.control.Try<T> tryObject)
        Flux from try. Try with null inside transforms to error event
        Type Parameters:
        T - the type parameter
        Parameters:
        tryObject - the try object
        Returns:
        the flux
      • tryFromMono

        public static <T> io.vavr.control.Try<T> tryFromMono​(reactor.core.publisher.Mono<T> mono)
        Try from Mono. Mono with error event transforms Failure
        Type Parameters:
        T - the type parameter
        Parameters:
        mono - the mono object
        Returns:
        the Try
      • tryFromFlux

        public static <T> io.vavr.control.Try<T> tryFromFlux​(reactor.core.publisher.Flux<T> flux)
        Try from Flux. Mono with error event transforms Failure
        Type Parameters:
        T - the type parameter
        Parameters:
        flux - the flux object
        Returns:
        the Try
      • functionToMonoParallel

        public static <T,​R> java.util.function.Function<T,​reactor.core.publisher.Mono<R>> functionToMonoParallel​(io.vavr.CheckedFunction1<T,​R> function,
                                                                                                                             reactor.core.scheduler.Scheduler scheduler)
        Alias for CheckedConsumer.unchecked()
        Type Parameters:
        T - return type
        R - the type parameter
        Parameters:
        function - the function
        scheduler - the scheduler
        Returns:
        An unchecked wrapper of supplied uncheckedFunction
      • functionToMonoParallelLogError

        public static <T,​R> java.util.function.Function<T,​reactor.core.publisher.Mono<R>> functionToMonoParallelLogError​(io.vavr.CheckedFunction1<T,​R> function,
                                                                                                                                     reactor.core.scheduler.Scheduler scheduler,
                                                                                                                                     java.lang.String message)
        Function to mono parallel log error function.
        Type Parameters:
        T - the type parameter
        R - the type parameter
        Parameters:
        function - the function
        scheduler - the scheduler
        message - the message
        Returns:
        the function
      • range

        public static reactor.core.publisher.Flux<java.lang.Integer> range​(int start,
                                                                           int end)
        Range of Integers from start to end, even in reverse order. Borders inclusive.
        Parameters:
        start - the start
        end - the end
        Returns:
        the flux
      • longRange

        public static reactor.core.publisher.Flux<java.lang.Long> longRange​(long start,
                                                                            long end)
        Range of Longs from start to end, even in reverse order. Borders inclusive.
        Parameters:
        start - the start
        end - the end
        Returns:
        the flux
      • indexed

        public static <E> reactor.core.publisher.Flux<io.vavr.Tuple2<java.lang.Integer,​E>> indexed​(reactor.core.publisher.Flux<E> flux)
        Indexed (with Integer) elements of Flux. Wrap element with index into Tuple2
        Type Parameters:
        E - the type parameter
        Parameters:
        flux - the flux
        Returns:
        the flux
      • longIndexed

        public static <E> reactor.core.publisher.Flux<io.vavr.Tuple2<java.lang.Long,​E>> longIndexed​(reactor.core.publisher.Flux<E> flux)
        Indexed (with Long) elements of Flux. Wrap element with index into Tuple2
        Type Parameters:
        E - the type parameter
        Parameters:
        flux - the flux
        Returns:
        the flux