title: Predicates java 8 with generics and inheritance
body: <p>I'm having three Foo Boo Goo objects with Boo and Goo subtypes of Foo super class.</p>
  
  <p>I'm using Predicates to filter lists as following</p>
  
  <pre><code>public class Predicates {
  
          public static Predicate&lt;Foo&gt; isBoo() {
              foo -&gt;  { 
                    Boo boo = (Boo) foo; 
                    return boo.isBoo();
               };
           }
  
      public static Predicate&lt;Goo&gt; isGoo() {
              foo -&gt;  { 
                    Goo goo = (Goo) foo; 
                    return goo.isGoo();
               };
       }
  }
  </code></pre>
  
  <p>What i want to acheive next is to have a generic type instead of compile-time types specified. </p>
  
  <pre><code>public class Predicates {
  
          public static &lt;T extends Foo&gt; Predicate&lt;T&gt; isBoo() {
              foo -&gt;  { 
                    // check both with instanceof
               };
           }
  
      public static &lt;T extends Foo&gt; Predicate&lt;T&gt; isGoo() {
              foo -&gt;  { 
                    Goo goo = (Goo) foo; 
                    return boo.isGoo();
               };
       }
  
      public static &lt;T extends Foo&gt; Predicate&lt;T&gt; isFoo() {
              isGoo().or(isBoo());
       }
  }
  </code></pre>
  
  <p>It seems impossible to use generics with Predicates when having anoter one combining multiples predicates with OR or AND. Knowing the predicates may have differents types buts still extends the super class.</p>
  
  <p>Need light!</p>