title: Applying a list of functions to a value with Java8 stream api
body: <p>I want a take a single log message pojo <code>LoggedExchange</code> and apply a bunch of transformations to it. The transformations are UnaryOperators in a list:</p>
  
  <pre><code>List&lt;ConditionalTransform&gt; transforms = new ArrayList&lt;&gt;();
  </code></pre>
  
  <p>where <code>ConditionalTransform</code> implements <code>UnaryOperator&lt;LoggedExchange&gt;</code> and my current solution is using reduce like this:</p>
  
  <pre><code>public LoggedExchange transform(LoggedExchange original) {
      return transforms.stream().reduce(original, (o, t) -&gt; t.apply(o), (m1, m2) -&gt; m2);
  }
  </code></pre>
  
  <p>Running this in parallel does not make sense, as there is no way to do the combining of two messages (the <code>(m1,m2) -&gt; m2</code> is there just to make the compiler happy).</p>
  
  <p>Is there a better way to do this (like somehow composing all the <code>ConditionalTranforms</code>?) and if not, should the <code>combiner</code> function throw an exception or something as I can't support parallel execution?</p>
  
  <p>The <a href="https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html#reduce-U-java.util.function.BiFunction-java.util.function.BinaryOperator-" rel="noreferrer">JavaDoc</a> states that most of these operations should be possible to do with <code>map</code> and <code>reduce</code> but I don't see how.</p>