com.extjs.gxt.ui.client.data.ModelReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gxt Show documentation
Show all versions of gxt Show documentation
Rich Internet Application Framework for GWT
/*
* Sencha GXT 2.3.1a - Sencha for GWT
* Copyright(c) 2007-2013, Sencha, Inc.
* [email protected]
*
* http://www.sencha.com/products/gxt/license/
*/
package com.extjs.gxt.ui.client.data;
import java.util.ArrayList;
import java.util.List;
/**
* A DataReader
implementation for Model
instances.
*/
public class ModelReader implements DataReader> {
@SuppressWarnings({"unchecked", "rawtypes"})
public ListLoadResult read(Object loadConfig, Object data) {
if (data instanceof ModelData) {
List list = new ArrayList();
list.add(data);
return newLoadResult(loadConfig, list);
} else if (data instanceof List) {
return newLoadResult(loadConfig, (List) data);
} else if (data instanceof ListLoadResult) {
return (ListLoadResult) data;
}
assert false : "Error converting data";
return null;
}
/**
* Template method that provides load result.
*
* @param models the models
* @return the load result
*/
protected ListLoadResult newLoadResult(Object loadConfig, List models) {
return new BaseListLoadResult(models);
}
}