package fastweb.domain.system;

/**
 * 封装得接口属性
 */
public class WrapperResult {
    private static final String DEFAULT_INFOTYPE = "error";
    /**
     * 接口相应是否正确
     */
    private boolean successful;
    /**
     * 接口的相应信息
     */
    private Object resultValue;
    /**
     * 接口的相应信息
     */
    private String resultHint;
    private String errorPage;
    private String type = "error";

    public WrapperResult() {
    }

    public static WrapperResult successWrapedResult(Object data) {
        return new WrapperResult(true, data, "", "", "");
    }

    public static WrapperResult failedWrappedResult(String exMessage) {
        return new WrapperResult(false, "", exMessage);
    }

    public static WrapperResult failedWrappedResult(String exMessage, String errorPage) {
        return new WrapperResult(false, "", exMessage, errorPage, "error");
    }

    public static WrapperResult failedWrappedResult(String exMessage, String errorPage, String type) {
        return new WrapperResult(false, "", exMessage, errorPage, type);
    }

    public WrapperResult(boolean isSuccess, Object data, String tip, String errorPage, String type) {
        this.successful = isSuccess;
        this.resultValue = data;
        this.resultHint = tip;
        this.errorPage = errorPage;
        this.type = type;
    }

    public WrapperResult(boolean isSuccess, Object data, String tip) {
        this.successful = isSuccess;
        this.resultValue = data;
        this.resultHint = tip;
    }

    public boolean isSuccessful() {
        return this.successful;
    }

    public void setSuccessful(boolean successful) {
        this.successful = successful;
    }

    public Object getResultValue() {
        return this.resultValue;
    }

    public void setResultValue(Object resultValue) {
        this.resultValue = resultValue;
    }

    public String getResultHint() {
        return this.resultHint;
    }

    public void setResultHint(String resultHint) {
        this.resultHint = resultHint;
    }

    public String getErrorPage() {
        return this.errorPage;
    }

    public void setErrorPage(String errorPage) {
        this.errorPage = errorPage;
    }

    public String getType() {
        return this.type;
    }

    public void setType(String type) {
        this.type = type;
    }
}
