zaccret
23 May 2008, 4:53 AM
There are some places where the use of generics can cause warnings with javac or eclipse compiler (and require us to add @SuppressWarnings). Maybe this is obvious to you, Darell, but maybe we can help in identify the places.
For now, I see these places :
- In Controller class. When we extend Controller, we get a warning on handleEvent(AppEvent) where AppEvent is a raw type and should be parameterized.
public abstract void handleEvent(AppEvent event); could be
public abstract void handleEvent(AppEvent<?> event);- In BaseModel. When I write a class extending BaseModel, I get those warnings in javac output concerning set and remove method
warning: remove(java.lang.String) in com.extjs.gxt.ui.client.data.BaseModel implements <X>remove(java.lang.String) in com.extjs.gxt.ui.client.data.ModelData; return type requires unchecked conversion
[javac] found : java.lang.Object
[javac] required: X
[javac] public class DefaultBaseModel extends BaseModel { So
public Object set(String name, Object value) {
Object oldValue = super.set(name, value);
notifyPropertyChanged(name, value, oldValue);
return oldValue;
}
...
public Object remove(String name) {
if (map.containsKey(name)) {
Object oldValue = super.remove(name);
notifyPropertyChanged(name, null, oldValue);
return oldValue;
}
return null;
}
could be
public <X> X set(String name, X value) {
X oldValue = super.set(name, value);
notifyPropertyChanged(name, value, oldValue);
return oldValue;
}
...
public <X> X remove(String name) {
if (map.containsKey(name)) {
X oldValue = super.remove(name);
notifyPropertyChanged(name, null, oldValue);
return oldValue;
}
return null;
}
Tell us if that helps, Darell, or if you already know these small issues.
For now, I see these places :
- In Controller class. When we extend Controller, we get a warning on handleEvent(AppEvent) where AppEvent is a raw type and should be parameterized.
public abstract void handleEvent(AppEvent event); could be
public abstract void handleEvent(AppEvent<?> event);- In BaseModel. When I write a class extending BaseModel, I get those warnings in javac output concerning set and remove method
warning: remove(java.lang.String) in com.extjs.gxt.ui.client.data.BaseModel implements <X>remove(java.lang.String) in com.extjs.gxt.ui.client.data.ModelData; return type requires unchecked conversion
[javac] found : java.lang.Object
[javac] required: X
[javac] public class DefaultBaseModel extends BaseModel { So
public Object set(String name, Object value) {
Object oldValue = super.set(name, value);
notifyPropertyChanged(name, value, oldValue);
return oldValue;
}
...
public Object remove(String name) {
if (map.containsKey(name)) {
Object oldValue = super.remove(name);
notifyPropertyChanged(name, null, oldValue);
return oldValue;
}
return null;
}
could be
public <X> X set(String name, X value) {
X oldValue = super.set(name, value);
notifyPropertyChanged(name, value, oldValue);
return oldValue;
}
...
public <X> X remove(String name) {
if (map.containsKey(name)) {
X oldValue = super.remove(name);
notifyPropertyChanged(name, null, oldValue);
return oldValue;
}
return null;
}
Tell us if that helps, Darell, or if you already know these small issues.