title: Is this possible to do using plain BiFunction in method definition
body: <p>I had the following problem: a method should take in a bi-function that takes 2 arguments - one is of type <code>Collection&lt;T&gt;</code> and the other is <code>T</code>; the actual function could be actually <code>Collection::remove</code> or <code>Collection::add</code>, or a more complex operation; the actual function is used for more than a dozen of collection and there are several types of values and collections in the function.</p>
  
  <p>Initially there was no genericity - there were just <code>Collection&lt;String&gt;</code>s and elements were <code>String</code>s so declaring the argument as <code>BiFunction&lt;Collection&lt;String&gt;, String, Boolean&gt;</code> worked just well:</p>
  
  <pre><code>List&lt;String&gt; idCodes;
  void visitElement(Element e, 
                    BiFunction&lt;Collection&lt;String&gt;, String, Boolean&gt; elementOp) {
      elementOp.apply(idCodes, e.getIdCode());
  }
  </code></pre>
  
  <p>However then I added other types of collections too, and found that I could no longer find out how to use <code>BiFunction</code> generically:</p>
  
  <pre><code>List&lt;String&gt; idCodes;
  List&lt;Integer&gt; weights;
  
  void visitElement(Element e, 
                    BiFunction&lt;...&gt; elementOp) {
      elementOp.apply(idCodes, e.getIdCode());
      elementOp.apply(weights, e.getWeight());
  }
  </code></pre>
  
  <p>but failed - I could just get compile errors in one place or another no matter what I used for type parameters it would fail.</p>
  
  <p>One of my attempts was</p>
  
  <pre><code>&lt;T&gt; void visitElement(Element e, 
                        BiFunction&lt;Collection&lt;T&gt;, T, Boolean&gt; elementOp) 
  </code></pre>
  
  <p>would fail not when passing in <code>Collection::add</code> but when actually applying the function to <code>Collection&lt;String&gt;</code> and <code>String</code>; or <code>Collection&lt;Integer&gt;</code> and <code>int</code>. </p>
  
  <p>Then I made another interface:</p>
  
  <pre><code>interface ElementOp {
      &lt;T&gt; boolean apply(Collection&lt;T&gt; collection, T item);
  }
  </code></pre>
  
  <p>And not so surprisingly this now works exactly as I wanted. Therefore my question is:</p>
  
  <p>Do I really have to use </p>
  
  <pre><code>interface ElementOp {
      &lt;T&gt; boolean apply(Collection&lt;T&gt; collection, T item);
  }
  
  void visitElement(Element e, 
                    ElementOp elementOp) {
      elementOp.apply(idCodes, e.getIdCode());
      elementOp.apply(weights, e.getWeight());
  }
  </code></pre>
  
  <p>or would it be somehow possible to use <code>BiFunction</code> for this case?</p>
  
  <p>P.S. I am using Eclipse 4.3 Mars Java compiler, so it might just be that this might not work because of a some bug there.</p>