title: In-memory transformations on a reactive stream in Project Reactor
body: <p>I have the following interface:</p>
  
  <pre><code>interface Checker {
    Mono&lt;Foo&gt; check(Bar bar);
  }
  </code></pre>
  
  <p>Also note that <code>Bar</code> has a method <code>getPizzas()</code>:</p>
  
  <pre><code>class Bar {
    List&lt;Pizza&gt; getPizzas() { ... }
  }
  </code></pre>
  
  <p>On some cases, the implementing class uses the benefit of non blocking IO operations, by using a reactive-enabled HTTP client.</p>
  
  <p>However, on other cases, there are no IO operations, so that I only want to use a method <code>transform</code> that takes <code>List&lt;Pizza&gt;</code> and returns an instance of <code>Foo</code> and would return it as a <code>Mono&lt;Foo&gt;</code>.</p>
  
  <p>The signature of <code>transform</code> is:</p>
  
  <pre><code>Foo transform(List&lt;Pizza&gt; pizzas) { ... }
  </code></pre>
  
  <p>From what I understand, I have two options (maybe more) to implement such Checker:</p>
  
  <p>Option [1.a] - use the reactive stream approach as much as possible:</p>
  
  <pre><code>Mono&lt;Foo&gt; check(Bar bar) {
    return Flux.fromIterable(bar.getPizzas()).collectList().map(pizzas -&gt; transform(pizzas));
  }
  </code></pre>
  
  <p>Option [1.b] - almost the same as [1.a]:</p>
  
  <pre><code>Mono&lt;Foo&gt; check(Bar bar) {
    return Mono.just(bar.getPizzas()).map(pizzas -&gt; transform(pizzas));
  }
  </code></pre>
  
  <p>Option [2] - use pure Java for in-memory transformation:</p>
  
  <pre><code>Mono&lt;Foo&gt; check(Bar bar) {
    return Mono.just(transform(bar.getPizzas()));
  }
  </code></pre>
  
  <p><strong>My questions:</strong></p>
  
  <p>Is there a difference in the options described above?</p>
  
  <p>Will using the reactive <code>map</code> be a better approach if <code>transform</code> is CPU intensive and takes a significant amount of time (say, more than 2 seconds)?</p>