Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Currently, the bound on your <code>Action</code> class says - <code>U extends User&lt;Principal&gt;</code>. Since <code>MyUser</code> deoesn't extend a <code>User&lt;Principal&gt;</code>, but a <code>User&lt;MyPrincipal&gt;</code>, it won't work as you expected. A <code>User&lt;MyPrincipal&gt;</code> is not a <code>User&lt;Principal&gt;</code> (distinct types).</p> <p>You can introduce another type parameter in your <code>Action</code> class, and use that in bounds of <code>U</code>:</p> <pre><code>public abstract class Action&lt;P extends Principal, U extends User&lt;P&gt;&gt; { } </code></pre> <p>and now, you can create your <code>MyAction</code> like this:</p> <pre><code>public class MyAction extends Action&lt;MyPrincipal, MyUser&gt;{ } </code></pre> <hr /> <p>Or you can also modify your class using wildcard bound:</p> <pre><code>public abstract class Action&lt;U extends User&lt;? extends Principal&gt;&gt; { } </code></pre> <p>This way you won't need another type parameter:</p> <pre><code>public class MyAction extends Action&lt;MyUser&gt;{ } </code></pre> <hr /> <p><strong>References:</strong></p> <ul> <li><a href="http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html" rel="nofollow">Java Generics FAQs</a> <ul> <li><a href="http://www.angelikalanger.com/GenericsFAQ/FAQSections/TypeParameters.html#Can%20I%20use%20a%20type%20parameter%20as%20part%20of%20its%20own%20bounds%20or%20in%20the%20declaration%20of%20other%20type%20parameters?" rel="nofollow">Can I use a type parameter as part of its own bounds?</a></li> </ul></li> </ul>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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