我正在尝试测试性能提示:https://groups.google.com/forum/#!msg/google-web-toolkit/f9FLCEloW-c/3ZelaqGUGTcJ
我有超过5种不同的Callback,它们具有不同的结果对象。
如何在一个静态类中创建动态静态类:
public class AsyncCallbacks
{
private static AsyncCallback<?> callback = null;
private AsyncCallbacks(){
}
private AsyncCallback<?> createCallback() {
if(callback == null) {
callback = new AsyncCallback(){
@Override
public void onFailure(Throwable caught)
{
// TODO Auto-generated method stub
}
@Override
public void onSuccess(Object result)
{
// TODO Auto-generated method stub
}
};
}
return callback;
}
}
答案 0 :(得分:0)
public class Asyncs implements AsyncCallback<Object> {
private Dto1 dto1 = null;
private Dto2 dto2 = null;
private Object result = null;
@Override
public void onFailure(Throwable caught) {
// failed message
}
@Override
public void onSuccess(Object result) {
this.result = result;
}
public Object getSuccessObject() {
if (result instanceof Dto1) {
dto1 = (Dto1) result;
} else if (result instanceof Dto2) {
dto2 = (Dto2) result;
}
return result;
}
}