title: Type casting using type parameter
body: <p>Given is a Java method that returns <code>java.lang.Object</code>s for a given string. I'd like to wrap this method in a Scala method that converts the returned instances to some type <code>T</code>. If the conversion fails, the method should return <code>None</code>. I am looking for something similar to this:</p>
  
  <pre><code>def convert[T](key: String): Option[T] = {
    val obj = someJavaMethod(key)
    // return Some(obj) if obj is of type T, otherwise None
  }
  
  convert[Int]("keyToSomeInt") // yields Some(1)
  convert[String]("keyToSomeInt") // yields None
  </code></pre>
  
  <p>(How) Can this be achieved using Scala's reflection API? I am well aware that the signature of <code>convert</code> might have to be altered.</p>