This commit is contained in:
地平线
2015-08-17 10:51:34 +08:00
parent 70e61dffda
commit ec7b1d7570
4 changed files with 605 additions and 0 deletions

View File

@@ -0,0 +1,94 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.wentch.redkale.service;
import com.wentch.redkale.convert.json.*;
/**
* 通用的结果对象
*
* @author zhangjx
* @param <T>
*/
public class RetResult<T> {
public static final RetResult SUCCESS = new RetResult() {
@Override
public void setRetcode(int retcode) {
}
@Override
public void setRetinfo(String retinfo) {
}
@Override
public void setResult(Object result) {
}
};
protected int retcode;
protected String retinfo;
private T result;
public RetResult() {
}
public RetResult(T result) {
this.result = result;
}
public RetResult(int retcode) {
this.retcode = retcode;
}
public RetResult(int retcode, String retinfo) {
this.retcode = retcode;
this.retinfo = retinfo;
}
public RetResult(int retcode, String retinfo, T result) {
this.retcode = retcode;
this.retinfo = retinfo;
this.result = result;
}
public boolean isSuccess() {
return retcode == 0;
}
public int getRetcode() {
return retcode;
}
public void setRetcode(int retcode) {
this.retcode = retcode;
}
public String getRetinfo() {
return retinfo;
}
public void setRetinfo(String retinfo) {
this.retinfo = retinfo;
}
public T getResult() {
return result;
}
public void setResult(T result) {
this.result = result;
}
@Override
public String toString() {
return JsonFactory.root().getConvert().convertTo(this);
}
}