Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So, you're trying to implement a workflow <strong>join</strong>. You want to take a pair continuation and turn it into two component continuations. I think there are race conditions in your implementation, but leaving that aside for the moment, let's talk about the types.</p> <p>If you're dead-set on allowing the component types to have names and be different from <code>A</code> and <code>B</code>, they need to be superclasses thereof (as you are going to get an A and a B back from your respective requests). Which is what you tried in the OP. Assuming <code>C</code> and <code>D</code> can only be <code>Entity</code>, turn the relationships around, and you can get it without using the <code>super</code> keyword where it isn't allowed:</p> <pre><code>public static &lt; C extends Entity, D extends Entity, A extends C, B extends D &gt; void doubleRequestExecute( Request&lt; A &gt; request1, Request&lt; B &gt; request2, Callback&lt; Pair&lt; C, D &gt; &gt; callback ) { ... } </code></pre> <p>For arbitrary <code>C</code> and <code>D</code> see my other answer. However, I think you can go as simply as</p> <pre><code>public static &lt; A extends Entity, B extends Entity &gt; void doubleRequestExecute( Request&lt; A &gt; request1, Request&lt; B &gt; request2, Callback&lt; ? super Pair&lt; A, B &gt; &gt; callback ) { // change all Cs to As and Ds to Bs in the original code } </code></pre> <p><em>if</em> you are willing to have calling code that looks like this (which I believe mimics @Flavio's answer):</p> <pre><code>doubleRequestExecute( new Request&lt;Entity&gt;(), new Request&lt;Entity&gt;(), new Callback&lt; Pair&lt; ?, ? &gt; &gt;() { @Override public void onSuccess(Pair&lt; ?, ? &gt; result) {} @Override public void onFailure(Throwable caught) {} } ); </code></pre> <p>You can also do</p> <pre><code>public static &lt; C, D &gt; void doubleRequestExecute( Request&lt; ? extends C &gt; reqA, Request&lt; ? extends D &gt; reqB, final Callback&lt; Pair&lt; C, D &gt; &gt; callback ) { // change all As to Cs and Bs to Ds in the original code } </code></pre> <p>(it seems Eclipse's Java is OK with the wildcards in the <code>Request</code> parameters not being expressly bounded by Entity) and call it exactly as you wished in the OP:</p> <pre><code>doubleRequestExecute( new Request&lt;Entity&gt;(), new Request&lt;Entity&gt;(), new Callback&lt; Pair&lt; Object, Object &gt; &gt;() { @Override public void onSuccess(Pair&lt; Object, Object &gt; result) {} @Override public void onFailure(Throwable caught) {} } ); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload