I've got the following code:
private HashMap<Class<?>, HashMap<Entity, ? extends Component>> m_componentStores;
public <T extends Component> T getComponent(Entity e, Class<T> exampleClass)
{
HashMap<Entity, ? extends Component> store = m_componentStores.get(exampleClass);
T result = (T)store.get(e);
if (result == null)
{
throw new IllegalArgumentException( "GET FAIL: "+e+" does not possess Component of class\nmissing: "+exampleClass );
}
return result;
}
When I compile, it shows that T result = (T)store.get(e)
has an unchecked cast.
Type safety: Unchecked cast from capture#2-of ? extends Component to T
What am I missing to prevent this warning from appearing?