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();

    }

  • 相关阅读:
    后缀数组 (Suffix Array) 学习笔记
    Miller-Rabin 素性测试 与 Pollard Rho 大整数分解
    [ USACO 2013 OPEN ] Photo
    清华集训2016做题记录
    「UNR#2」黎明前的巧克力
    「UNR#1」奇怪的线段树
    Atcoder Grand Contest 018 E
    「NOI2015」小园丁与老司机
    「集训队作业2018」三角形
    Codeforces 878 E. Numbers on the blackboard
  • 原文地址:https://www.cnblogs.com/kekang/p/5609976.html
Copyright © 2011-2022 走看看