title: How to make a future dependent on two others in Java
body: <p>I have a future that would ideally take two parameters coming from two other futures. For this I have .thenCombine(), the trick here is that the second future needs the result of the first one.</p>
  
  <p>Let's say:</p>
  
  <ul>
  <li>I have futures A, B and C</li>
  <li>Future B needs the result of future A</li>
  <li>Future C needs the result of future A and B</li>
  </ul>
  
  <p>I would like to have something like:</p>
  
  <pre><code>CompletableFuture&lt;Customer&gt; customerFuture = CompletableFuture.supplyAsync(() -&gt; findCustomer(123));
  CompletableFuture&lt;Shop&gt; shopFuture         = CompletableFuture.supplyAsync((customer) -&gt;getAllAccessibleShops(customer));
  CompletableFuture&lt;Route&gt; routeFuture       = customerFuture.thenCombine(shopFuture, (cust, shop) -&gt; findRoute(cust, shop));
  </code></pre>
  
  <p>Of course thenCombine() is not what I'm looking for and the code above looks dumb because I shouldn't need the customer afterwards, but this is only an example.</p>
  
  <p>Is there a way to achieve this?</p>