Class PublisherPipes

java.lang.Object
io.inverno.mod.irt.PublisherPipes

public final class PublisherPipes extends Object

A collection of pipes used to transform publishers including: filter, sort, map, flatMap...

Since:
1.2
Author:
Jeremy Kuhn
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T, R> PublisherPipe<T,R>
    concatMap(Function<? super T,? extends Publisher<? extends R>> mapper)
    Returns a pipe which transforms the elements of a publisher into publishers by applying the specified mapper function then flatten, these inner publishers into a single publisher, sequentially and preserving order using concatenation.
    static <T> PublisherPipe<T,T>
    Returns a pipe which converts a publisher to filter out duplicates.
    static <T, U> Function<? super Publisher<T>,? extends Publisher<T>>
    distinct(Function<? super T,? extends U> keySelector)
    Returns a pipe which converts a publisher to filter out duplicates based on their keys computed using the specified key selector.
    static <T, U> PublisherPipe<T,T>
    filter(Function<? super T,? extends U> keySelector, Predicate<? super U> predicate)
    Returns a pipe which converts a publisher to filter out elements based on their keys computed using the specified key selector that do not pass the specified predicate test.
    static <T> PublisherPipe<T,T>
    filter(Predicate<? super T> predicate)
    Returns a pipe which converts a publisher to filter out elements that do not pass the specified predicate test.
    static <T, R> PublisherPipe<T,R>
    flatMap(Function<? super T,? extends Publisher<? extends R>> mapper)
    Returns a pipe which transforms the elements of a publisher into publishers by applying the specified mapper function, then flatten these inner publishers into a single publisher through merging, which allow them to interleave.
    static <T, R> PublisherPipe<T,R>
    flatMapSequential(Function<? super T,? extends Publisher<? extends R>> mapper)
    Returns a pipe which transforms the elements of a publisher into publishers by applying the specified mapper function, then flatten these inner publishers into a single Flux, but merge them in the order of their source element.
    static <T, R> PublisherPipe<T,R>
    map(Function<? super T,? extends R> mapper)
    Returns a pipe which transforms the elements of a publisher by applying the specified mapper function.
    static <T> PublisherPipe<T,T>
    Returns a pipe which converts a publisher to sort the elements in natural order.
    static <T> PublisherPipe<T,T>
    sort(Comparator<? super T> comparator)
    Returns a pipe which converts a publisher to sort the elements using the specified comparator.

    Methods inherited from class java.lang.Object

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

    • PublisherPipes

      public PublisherPipes()
  • Method Details

    • distinct

      public static <T> PublisherPipe<T,T> distinct()

      Returns a pipe which converts a publisher to filter out duplicates.

      Type Parameters:
      T - the type of element in the publisher
      Returns:
      a publisher pipe
    • distinct

      public static <T, U> Function<? super Publisher<T>,? extends Publisher<T>> distinct(Function<? super T,? extends U> keySelector)

      Returns a pipe which converts a publisher to filter out duplicates based on their keys computed using the specified key selector.

      Type Parameters:
      T - the type of element in the publisher
      U - the type of the computed keys
      Parameters:
      keySelector - a key selector
      Returns:
      a publisher pipe
    • sort

      public static <T> PublisherPipe<T,T> sort()

      Returns a pipe which converts a publisher to sort the elements in natural order.

      Type Parameters:
      T - the type of element in the publisher
      Returns:
      a publisher pipe
    • sort

      public static <T> PublisherPipe<T,T> sort(Comparator<? super T> comparator)

      Returns a pipe which converts a publisher to sort the elements using the specified comparator.

      Type Parameters:
      T - the type of element in the publisher
      Parameters:
      comparator - a comparator
      Returns:
      a publisher pipe
    • filter

      public static <T> PublisherPipe<T,T> filter(Predicate<? super T> predicate)

      Returns a pipe which converts a publisher to filter out elements that do not pass the specified predicate test.

      Type Parameters:
      T - the type of element in the publisher
      Parameters:
      predicate - a predicate
      Returns:
      a publisher pipe
    • filter

      public static <T, U> PublisherPipe<T,T> filter(Function<? super T,? extends U> keySelector, Predicate<? super U> predicate)

      Returns a pipe which converts a publisher to filter out elements based on their keys computed using the specified key selector that do not pass the specified predicate test.

      Type Parameters:
      T - the type of element in the publisher
      U - the type of the computed keys
      Parameters:
      keySelector - a key selector
      predicate - a predicate
      Returns:
      a publisher pipe
    • map

      public static <T, R> PublisherPipe<T,R> map(Function<? super T,? extends R> mapper)

      Returns a pipe which transforms the elements of a publisher by applying the specified mapper function.

      Type Parameters:
      T - the type of element in the publisher
      R - the type of element in the resulting publisher
      Parameters:
      mapper - a mapper function
      Returns:
      a publisher pipe
    • concatMap

      public static <T, R> PublisherPipe<T,R> concatMap(Function<? super T,? extends Publisher<? extends R>> mapper)

      Returns a pipe which transforms the elements of a publisher into publishers by applying the specified mapper function then flatten, these inner publishers into a single publisher, sequentially and preserving order using concatenation.

      Type Parameters:
      T - the type of element in the publisher
      R - the type of element in the resulting publisher
      Parameters:
      mapper - a mapper function
      Returns:
      a publisher pipe
    • flatMap

      public static <T, R> PublisherPipe<T,R> flatMap(Function<? super T,? extends Publisher<? extends R>> mapper)

      Returns a pipe which transforms the elements of a publisher into publishers by applying the specified mapper function, then flatten these inner publishers into a single publisher through merging, which allow them to interleave.

      Type Parameters:
      T - the type of element in the publisher
      R - the type of element in the resulting publisher
      Parameters:
      mapper - a mapper function
      Returns:
      a publisher pipe
    • flatMapSequential

      public static <T, R> PublisherPipe<T,R> flatMapSequential(Function<? super T,? extends Publisher<? extends R>> mapper)

      Returns a pipe which transforms the elements of a publisher into publishers by applying the specified mapper function, then flatten these inner publishers into a single Flux, but merge them in the order of their source element.

      Type Parameters:
      T - the type of element in the publisher
      R - the type of element in the resulting publisher
      Parameters:
      mapper - a mapper function
      Returns:
      a publisher pipe