Result || IResult

Posted 追恋KG

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Result || IResult相关的知识,希望对你有一定的参考价值。

package com.credithc;

import com.fasterxml.jackson.annotation.JsonAutoDetect;

@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
public class Result<T> implements IResult<T> {

protected T data;
protected int code;

protected String msg;
/**
* 执行成功
*/
public static final int OK = 0;

/**
* 执行失败
*/
public static final int FAIL = 1;

public static final String MSG_SUCCESS= "SUCCESS";

public Result() {

}

public Result(T data) {
super();
this.data = data;
this.code = OK;
this.msg = MSG_SUCCESS;
}

public Result(T data, int code) {
super();
this.data = data;
this.code = code;
}
public Result(T data, int code,String msg) {
super();
this.data = data;
this.code = code;
this.msg=msg;
}

public T getData() {
return data;
}

public void setData(T data) {
this.data = data;
}

public int getCode() {
return code;
}

public void setCode(int code) {
this.code = code;
}

public boolean oked() {
// TODO Auto-generated method stub
return this.code == OK;
}

public boolean failed() {
// TODO Auto-generated method stub
return this.code == FAIL;
}

public String getMsg() {
return msg;
}

public void setMsg(String msg) {
this.msg = msg;
}

}

 

 

//***********************************************

package com.credithc;

import java.io.Serializable;

 


public interface IResult<T> extends Serializable {
public T getData();
public int getCode();
public boolean oked();
public boolean failed();

}

以上是关于Result || IResult的主要内容,如果未能解决你的问题,请参考以下文章

C# 'unsafe' 函数 - *(float*)(&result) 与 (float)(result)

mysqli_store_result() 与 mysqli_use_result()

Struts2系列:result-type和全局result

get_result --perl

Struts 2的Result Type

Rust Diesel 原始 SQL 给出错误“`std::result::Result<Vec<T>,diesel::result::Error>` 所需的类型注释”