我有這兩個類,我需要在父類的子類filds中進行初始化。Java泛型語法設置器
public class A {
protected LazyFacade<E> list;
protected LazyDataModel<E> model;
protected MyObject myObject;
protected LazyDataModel<E> buildModel() {
lazyModel = new LazyDataModel<E>() {
public List<E> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
List<E> resultList = null;
try {
setRowCount((int) list.countObjects(myObject, filters));
resultList = list.listObject(myObject, first, pageSize, sortField, sortOrder, filters);
} catch (PersistenceException e) {
}
return resultList;
}
};
return lazyModel;
}
//getters setters
}
public class B extends A {
public B() {
this.list = new LazyFacade<OtherClass>(); **//is it correct way to instantiate the list???**
this.myObject = getObjectInDataBase();
this.model = buildModel(); **//the model must have the same class of LazyFacade, in this case OtherClass.
//How could i do it?**
}
}
有什麼問題嗎?你認爲'E'是什麼? – SLaks