package com.ltl.common.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.io.Serializable;
/**通用数据传输对象
* @author Json y
* @date 2021/2/5 21:22
*/
@Data
public class ResponseResult<T> implements Serializable {
private static final long serialVersionUID = 3468352004150968551L;
/**
* 状态码
*/
private Integer code;
/**
* 消息
*/
private String message;
/**
* 返回对象
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
private T data;
public ResponseResult() {
super();
}
public ResponseResult(Integer code) {
super();
this.code = code;
}
public ResponseResult(Integer code, String message) {
super();
this.code = code;
this.message = message;
}
public ResponseResult(Integer code, Throwable throwable) {
super();
this.code = code;
this.message = throwable.getMessage();
}
public ResponseResult(Integer code, T data) {
super();
this.code = code;
this.data = data;
}
public ResponseResult(Integer code, String message, T data) {
super();
this.code = code;
this.message = message;
this.data = data;
}
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 + ((code == null) ? 0 : code.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 (code == null) {
if (other.code != null) {
return false;
}
} else if (!code.equals(other.code)) {
return false;
}
return true;
}
}
网友评论