title: Check if an object is an instance of a class (but not an instance of its subclass)
body: <p>For this example:</p>
  <pre><code>public class Foo{}
  
  public class Bar extends Foo{}
  
  ....
  
  void myMethod(Foo qux){
     if (checkInstance(qux,Foo.class)){
       ....
     }
  }
  </code></pre>
  <p>How can I check if <code>qux</code> is an instance of Foo (but not an instance of its subclass of foo)? That is:</p>
  <ul>
  <li>checkInstance(qux,Foo.class)=true</li>
  <li>checkInstance(qux,Bar.class)=false</li>
  </ul>
  <p>Is there some kind of statement like <code>instanceof</code> for this check? or I should use <code>qux.getClass().equals(Foo.class)</code></p>