Klasse PairFlux<LeftT,RightT>

java.lang.Object
de.kamillionlabs.hateoflux.utility.pair.PairFlux<LeftT,RightT>
Typparameter:
LeftT - the type of the left element in the pair
RightT - the type of the right element in the pair

public final class PairFlux<LeftT,RightT> extends Object
Wraps a Flux of Pair objects, providing convenient factory methods to create reactive streams of pairs.
Siehe auch:
  • Methodendetails

    • empty

      public static <LeftT, RightT> PairFlux<LeftT,RightT> empty()
      Creates an empty PairFlux.
      Typparameter:
      LeftT - the type of the left element in the pair
      RightT - the type of the right element in the pair
      Gibt zurück:
      a new empty PairFlux instance
    • of

      public static <LeftT, RightT> PairFlux<LeftT,RightT> of(reactor.core.publisher.Flux<Pair<LeftT,RightT>> flux)
      Creates a PairFlux from an existing Flux of Pair objects.
      Typparameter:
      LeftT - the type of the left element in the pair
      RightT - the type of the right element in the pair
      Parameter:
      flux - the Flux emitting Pair objects
      Gibt zurück:
      a new PairFlux instance wrapping the provided Flux
    • fromIterable

      public static <LeftT, RightT> PairFlux<LeftT,RightT> fromIterable(Iterable<Pair<LeftT,RightT>> iterable)
      Creates a PairFlux from an Iterable of Pair objects (e.g. from a PairList).
      Typparameter:
      LeftT - the type of the left element in the pair
      RightT - the type of the right element in the pair
      Parameter:
      iterable - the Iterable containing Pair objects
      Gibt zurück:
      a new PairFlux emitting the pairs from the provided Iterable
    • zipWith

      public static <LeftT, RightT> PairFlux<LeftT,RightT> zipWith(reactor.core.publisher.Flux<LeftT> flux, Function<LeftT,reactor.core.publisher.Mono<RightT>> mapper)
      Zips a Flux with a corresponding Mono to create a PairFlux.

      Usage example:

       Flux<Book> books = getBooksOnTopic("coding");
      
       // given getAuthorByBookTitle() returns Mono< Author>
       PairFlux<Book, Author> pairFlux =
               PairFlux.zipWith(books, book -> getAuthorByBookTitle(book.getTitle()));
       
      Typparameter:
      LeftT - the type of the left element in the pair
      RightT - the type of the right element in the pair
      Parameter:
      flux - the Flux emitting the first elements of the pair
      mapper - a function that maps each element to a Mono emitting the corresponding second element
      Gibt zurück:
      a new PairFlux instance emitting zipped pairs of elements
    • from

      public static <LeftT> PairFlux.Builder<LeftT> from(reactor.core.publisher.Flux<LeftT> flux)
      Initiates building a PairFlux by providing the first Flux. Should be used with PairFlux.Builder.with(java.util.function.Function<LeftT, reactor.core.publisher.Mono<RightT>>).

      Usage example:

       Flux<Book> books = getBooksOnTopic("coding");
      
       // given getAuthorByBookTitle() returns Mono< Author>
       PairFlux<Book, Author> pairFlux =
               PairFlux.from(books)
                       .with(book -> getAuthorByBookTitle(book.getTitle()));
       
      Typparameter:
      LeftT - the type of the left element in the pair
      Parameter:
      flux - the Flux emitting the first elements of the pair
      Gibt zurück:
      a PairFlux.Builder to continue building the PairFlux