title: Generic method in Groovy
body: <p>I'm currently learning Groovy and I got stuck with generic methods. </p>
  
  <p>I'd like to define generic method with generic return type that is inferred from argument type.</p>
  
  <p>In Java the signature would be:</p>
  
  <pre><code>&lt;T&gt; T getBean(String name, Class&lt;T&gt; requiredType);
  </code></pre>
  
  <p>How can I achieve it in Groovy?</p>