Grandiosa
10 Jun 2008, 1:44 AM
The ModelReader class:
public class ModelReader<C> implements DataReader<C, ListLoadResult<ModelData>> {
public ListLoadResult read(C loadConfig, Object data) {
if (data instanceof ModelData) {
List list = new ArrayList();
list.add(data);
return new BaseListLoadResult(list);
} else if (data instanceof List) {
return new BaseListLoadResult((List) data);
} else if (data instanceof ListLoadResult) {
return (ListLoadResult)data;
} else {
throw new RuntimeException("Error converting data");
}
}
The loadConfig object is unused. If the incoming data is a list, shouldn't the ModelReader only return a subset of the list? I mean if the loadConfig parameter is a BasePagingLoadConfig object ?
This is needed in a custom proxy's load method using this code:
PagingLoadResult<Data> result ;
result = reader.read(config, data);
where data is of type Data, and can be set by the user at any time.
The reader object would be a ModelReader if the BasePagingLoader was constructed with this reader as an argument.
public class ModelReader<C> implements DataReader<C, ListLoadResult<ModelData>> {
public ListLoadResult read(C loadConfig, Object data) {
if (data instanceof ModelData) {
List list = new ArrayList();
list.add(data);
return new BaseListLoadResult(list);
} else if (data instanceof List) {
return new BaseListLoadResult((List) data);
} else if (data instanceof ListLoadResult) {
return (ListLoadResult)data;
} else {
throw new RuntimeException("Error converting data");
}
}
The loadConfig object is unused. If the incoming data is a list, shouldn't the ModelReader only return a subset of the list? I mean if the loadConfig parameter is a BasePagingLoadConfig object ?
This is needed in a custom proxy's load method using this code:
PagingLoadResult<Data> result ;
result = reader.read(config, data);
where data is of type Data, and can be set by the user at any time.
The reader object would be a ModelReader if the BasePagingLoader was constructed with this reader as an argument.