com.alogic.remote.call.AbstractResult Maven / Gradle / Ivy
package com.alogic.remote.call;
import java.util.Map;
import com.anysoft.util.JsonSerializer;
/**
* Result的虚基类
* @author sony
*
* @since 1.2.9.3
* @version 1.6.8.13 [duanyy 20170427]
* - 从alogic-remote中迁移过来
*/
abstract public class AbstractResult implements Result{
public data getData(String id,
Class clazz) {
data result = null;
Object found = getData(id);
if (found != null){
if (found instanceof Map){
@SuppressWarnings("unchecked")
Map map = (Map) found;
try {
result = clazz.newInstance();
result.fromJson(map);
} catch (Exception e) {
// error occurs
}
}
}
return result;
}
public data getData(String id, data result) {
Object found = getData(id);
if (found != null){
if (found instanceof Map){
@SuppressWarnings("unchecked")
Map map = (Map) found;
result.fromJson(map);
}
}
return result;
}
public data getData(String id, Builder builder) {
data result = null;
Object found = getData(id);
if (found != null){
if (builder != null){
result = builder.deserialize(id, found);
}
}
return result;
}
}