title: Generics Type casting?
body: <p>In a abstract factory pattern i am using generics.
  I have BaseEntity interface which extends Serializable, the Employee class implements the BaseEntity. 
  In the abstract class i have this getJavaObj method</p>
  
  <p><code>getJavaObj()</code> is a method which takes a <code>Long empId</code> and returns a <code>Map&lt;String, ? extends BaseEntity&gt;</code></p>
  
  <pre><code>public abstract Map&lt;String, ? extends BaseEntity&gt; getJavaObj(Long id);
  </code></pre>
  
  <p>Using generics i am trying to do this in the main class it gives;</p>
  
  <pre><code>Map&lt;String, Employee&gt; emp = getJavaObj(empId);
  </code></pre>
  
  <p>It gives this error Type safety: <strong>Unchecked cast from <code>Map&lt;String,capture#1-of ? extends BaseEntity&gt;</code> to Map</strong></p>
  
  <p>When i do the type casting like this </p>
  
  <pre><code>Map&lt;String, Employee&gt; emp = (Map&lt;String, Employee&gt;)getJavaObj(empId);
  </code></pre>
  
  <p>It gives this warning </p>
  
  <blockquote>
    <p>Type safety: Unchecked cast from <code>Map&lt;String,capture#1-of ? extends Serializable&gt;</code> to 
                 Map
    Type safety: Unchecked cast from <code>Map&lt;String,capture#1-of ? extends BaseEntity&gt;</code> to 
                 Map</p>
  </blockquote>
  
  <p><strong>Is there a way to avoid type-casting or resolve the warnings even after typecasting?</strong> Since the object i am returning does extend to the Serializable via BaseEntity interface.</p>