title: java generic String to <T> parser
body: <p>Is there a straight-forward way to implement a method with the following signature? At minimum, the implementation would need to handle primitive types (e.g. Double and Integer). Non-primitive types would be a nice bonus.</p>
  
  <pre><code>//Attempt to instantiate an object of type T from the given input string
  //Return a default value if parsing fails   
  static &lt;T&gt; T fromString(String input, T defaultValue)
  </code></pre>
  
  <p>Implementation would be trivial for objects that implemented a FromString interface (or equivalent), but I haven't found any such thing. I also haven't found a functional implementation that uses reflection.</p>