J
Jason Cavett
Class modelClass = Class.forName(modelResult.getNodeValue());
Class viewClass = Class.forName(viewResult.getNodeValue());
factory.put(modelClass, viewClass);
I get the warning with the first two lines:
Class is a raw type. References to generic type Class<T> should be
parameterized
So, I tried this...
Class<?> modelClass = Class.forName(modelResult.getNodeValue());
Class<?> viewClass = Class.forName(viewResult.getNodeValue());
factory.put(modelClass, viewClass);
It removes those warnings, but I then get an error at the third line:
The method put(Class<? extends DataModel>, Class<? extends
PropertiesView>) in the type PropertiesFactory is not applicable for
the arguments (Class<capture#3-of ?>, Class<capture#4-of ?>)
So, I figured maybe there was a way to do something like this:
Class<? extends DataModel> modelClass = (Class<? extends DataModel)
Class.forName(modelResult.getNodeValue());
Class<? extends PropertiesView> viewClass = (Class<? extends
PropertiesView) Class.forName(viewResult.getNodeValue());
factory.put(modelClass, viewClass);
Which results in the two warnings:
Type safety: Unchecked cast from Class<capture#1-of ?> to Class<?
extends DataModel>
and
Type safety: Unchecked cast from Class<capture#1-of ?> to Class<?
extends PropertiesView>
At this point, it just seems easiest to use
@SuppressWarnings("unchecked") and ignore the warnings completely.
But, I was wondering if there was something I'm not understanding or
if there's a better way to do what I am trying to accomplish (no
warnings w/ everything cast correctly).
Thanks
Class viewClass = Class.forName(viewResult.getNodeValue());
factory.put(modelClass, viewClass);
I get the warning with the first two lines:
Class is a raw type. References to generic type Class<T> should be
parameterized
So, I tried this...
Class<?> modelClass = Class.forName(modelResult.getNodeValue());
Class<?> viewClass = Class.forName(viewResult.getNodeValue());
factory.put(modelClass, viewClass);
It removes those warnings, but I then get an error at the third line:
The method put(Class<? extends DataModel>, Class<? extends
PropertiesView>) in the type PropertiesFactory is not applicable for
the arguments (Class<capture#3-of ?>, Class<capture#4-of ?>)
So, I figured maybe there was a way to do something like this:
Class<? extends DataModel> modelClass = (Class<? extends DataModel)
Class.forName(modelResult.getNodeValue());
Class<? extends PropertiesView> viewClass = (Class<? extends
PropertiesView) Class.forName(viewResult.getNodeValue());
factory.put(modelClass, viewClass);
Which results in the two warnings:
Type safety: Unchecked cast from Class<capture#1-of ?> to Class<?
extends DataModel>
and
Type safety: Unchecked cast from Class<capture#1-of ?> to Class<?
extends PropertiesView>
At this point, it just seems easiest to use
@SuppressWarnings("unchecked") and ignore the warnings completely.
But, I was wondering if there was something I'm not understanding or
if there's a better way to do what I am trying to accomplish (no
warnings w/ everything cast correctly).
Thanks