title: Generic-Class with java.nio.Buffer
body: <p>An API-call is defined for different Buffer-classes:</p>
  
  <pre><code>apicall(ByteBuffer buffer);
  apicall(FloatBuffer buffer);
  apicall(IntBuffer buffer);
  apicall(LongBuffer buffer);
  apicall(DoubleBuffer buffer);
  </code></pre>
  
  <p>I need to write some classes working with that, but instead of writing five classes I want to use a generic class.</p>
  
  <pre><code>MyClass&lt;T extends Buffer&gt; ...
  </code></pre>
  
  <p>The Problem with that is, that apicall() is not defined for every Buffer, i.e. not for CharBuffer.</p>
  
  <pre><code>myMethod(T buffer) {apicall(buffer);}
  </code></pre>
  
  <p>fails. My workaround is something like this:</p>
  
  <pre><code>if (buffer instanceof FloatBuffer) {
      apicall((FloatBuffer)buffer);
  } else if (buffer instanceof ByteBuffer) {
      apicall((ByteBuffer)buffer);
  } else ...
  </code></pre>
  
  <p>I don't feel well with this. My question is, if there is a better way to solve my problem.</p>