title: Java 8 Completable Futures allOf different data types
body: <p>I have 3 CompletableFutures all 3 returning different data types.</p>
  
  <p>I am looking to create a result object that is a composition of the result returned by all the 3 futures.</p>
  
  <p>So my current working code looks like this:</p>
  
  <pre><code>public ClassD getResultClassD() {
  
      ClassD resultClass = new ClassD();
      CompletableFuture&lt;ClassA&gt; classAFuture = CompletableFuture.supplyAsync(() -&gt; service.getClassA() );
      CompletableFuture&lt;ClassB&gt; classBFuture = CompletableFuture.supplyAsync(() -&gt; service.getClassB() );
      CompletableFuture&lt;ClassC&gt; classCFuture = CompletableFuture.supplyAsync(() -&gt; service.getClassC() );
  
      CompletableFuture.allOf(classAFuture, classBFuture, classCFuture)
                       .thenAcceptAsync(it -&gt; {
                          ClassA classA = classAFuture.join();
                          if (classA != null) {
                              resultClass.setClassA(classA);
                          }
  
                          ClassB classB = classBFuture.join();
                          if (classB != null) {
                              resultClass.setClassB(classB);
                          }
  
                          ClassC classC = classCFuture.join();
                          if (classC != null) {
                              resultClass.setClassC(classC);
                          }
  
                       });
  
      return resultClass;
  }
  </code></pre>
  
  <p>My questions are: </p>
  
  <ol>
  <li><p>My assumption here is that since I am using <code>allOf</code> and <code>thenAcceptAsync</code>    this call will be non blocking. Is my understanding right ?</p></li>
  <li><p>Is this the right way to deal with multiple futures returning different result types ?</p></li>
  <li><p>Is it right to construct <code>ClassD</code> object within <code>thenAcceptAsync</code> ?</p></li>
  <li>Is it appropriate to use the <code>join</code> or <code>getNow</code> method in the thenAcceptAsync lambda ? </li>
  </ol>