Ajax响应工具类

封装了响应Ajax所需的状态码,提示信息,数据。


package cn.gitbetter.bean;



import java.io.Serializable;


public class ResponseResult<T> implements Serializable {


private static final long serialVersionUID = 2631551397189721626L;


private Integer state;
private String message;
private T data;


public ResponseResult() {
super();
}


public ResponseResult(Integer state) {
super();
this.state = state;
}


public ResponseResult(Integer state, String message) {
super();
this.state = state;
this.message = message;
}

public ResponseResult(Integer state, Throwable throwable) {
super();
this.state = state;
this.message = throwable.getMessage();
}


public ResponseResult(Integer state, T data) {
super();
this.state = state;
this.data = data;
}


public ResponseResult(Integer state, String message, T data) {
super();
this.state = state;
this.message = message;
this.data = data;
}


public Integer getState() {
return state;
}


public void setState(Integer state) {
this.state = state;
}


public String getMessage() {
return message;
}


public void setMessage(String message) {
this.message = message;
}


public T getData() {
return data;
}


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


@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((data == null) ? 0 : data.hashCode());
result = prime * result + ((message == null) ? 0 : message.hashCode());
result = prime * result + ((state == null) ? 0 : state.hashCode());
return result;
}


@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ResponseResult<?> other = (ResponseResult<?>) obj;
if (data == null) {
if (other.data != null)
return false;
} else if (!data.equals(other.data))
return false;
if (message == null) {
if (other.message != null)
return false;
} else if (!message.equals(other.message))
return false;
if (state == null) {
if (other.state != null)
return false;
} else if (!state.equals(other.state))
return false;
return true;
}


@Override
public String toString() {
return "ResponseResult [state=" + state + ", message=" + message + ", data=" + data + "]";
}


}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值