title: In Java, can I specify any amount of generic type parameters?
body: <p>I am looking to create a particular type of interface in Java <em>(although this is just as applicable to regular classes)</em>. This interface would need to contain some method, say, <code>invoke</code>; it would be called with a varying amount of parameters depending on the generic type arguments supplied.</p>
  
  <p>As an example:</p>
  
  <pre><code>public interface Foo&lt;T...&gt; {
      public void invoke(T... args);
  }
  
  // In some other class
  public static Foo&lt;Float, String, Integer&gt; bar = new Foo&lt;Float, String, Integer&gt;() {
      @Override
      public void invoke(Float arg1, String arg2, Integer arg3) {
          // Do whatever
      }
  };
  </code></pre>
  
  <p>To explain, briefly, how this could be used <em>(and provide some context)</em>, consider a class <code>Delegator</code>: the class takes a varying number of generic types, and has a single method - <code>invoke</code>, with these parameter types. The method passes on its parameters to an object in a list: an instance of <code>IDelegate</code>, which takes the same generic types. This allows <code>Delegator</code> to choose between several delegate methods (defined inside <code>IDelegate</code>) without having to create a new class for each specific list of parameter types.</p>
  
  <p>Is anything like this available? I have read about <a href="https://en.wikipedia.org/wiki/Variadic_template">variadic templates</a> in C++, but cannot find anything similar in Java. Is any such thing available? If not, what would be the cleanest way to emulate the same data model?</p>