我正在使用HashMap和下面的方法来跟踪类类型的更改监听器。IDE发出了警告。
需要指定哪种类型的Class才能解决警告?
[rawtypes] found raw type: java.lang.Class
missing type parameters for generic class java.lang.Class<T>.
需要指定哪种类型的Class才能解决警告?
private HashMap<Class, Set<ChangeListener>> classChangeListeners;
/**
* Adds a ChangeListener to the listener list for the specified class type. The class type
* specified must be a subclass of {@link BusinessObject}.
*
* @param <T> the type of BusinessObject.
* @param cls the class type.
* @param listener the ChangeListener to be added.
*/
public <T extends BusinessObject> void addChangeListener(Class<T> cls, ChangeListener listener)
{
if (!classChangeListeners.containsKey(cls))
{
classChangeListeners.put(cls, new TreeSet<ChangeListener>());
}
classChangeListeners.get(cls).add(listener);
}