zoukankan      html  css  js  c++  java
  • 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();

    }

  • 相关阅读:
    SharePoint的安装配置
    onkeypress与onkeydown及 oncopy和onpaste 事件区别详细说明
    sql Server 的基本函数
    iOS 错误 之 http请求
    iOS 错误及解决汇总
    iOS 开源库 之 AFNetWorking 2.x
    linux 下 tomcat 之 配置静态资源路径
    iOS 之 Block Variable
    iOS 协议
    #import与@class的区别
  • 原文地址:https://www.cnblogs.com/kekang/p/5609976.html
Copyright © 2011-2022 走看看