I am pretty sure this is type safe, but just wanted to check as Eclipse is asking me to put a @SuppressWarnings("unchecked")
annotation.
Map<String, IFace> faces;
public <T extends IFace> T getFace(String key)
{
return (T) faces.get(key);
}
It is not type safe. You are upcasting here so if you cast to an incompatible derived class you will come across an error at some point.
For example if A_Face
and B_Face
both extend IFace
. You might at some point be casting a B_Face
as an A_Face
which is not type safe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With