com.github.datalking.web.http.ResponseEntity Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of play-mvc Show documentation
Show all versions of play-mvc Show documentation
simple mvc framework based on java servlet.
The newest version!
package com.github.datalking.web.http;
import com.github.datalking.common.MultiValueMap;
import com.github.datalking.util.ObjectUtils;
/**
* HttpEntity + 状态码
*/
public class ResponseEntity extends HttpEntity {
private final HttpStatus statusCode;
public ResponseEntity(HttpStatus statusCode) {
super();
this.statusCode = statusCode;
}
public ResponseEntity(T body, HttpStatus statusCode) {
super(body);
this.statusCode = statusCode;
}
public ResponseEntity(MultiValueMap headers, HttpStatus statusCode) {
super(headers);
this.statusCode = statusCode;
}
public ResponseEntity(T body, MultiValueMap headers, HttpStatus statusCode) {
super(body, headers);
this.statusCode = statusCode;
}
public HttpStatus getStatusCode() {
return this.statusCode;
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ResponseEntity) || !super.equals(other)) {
return false;
}
ResponseEntity> otherEntity = (ResponseEntity>) other;
return ObjectUtils.nullSafeEquals(this.statusCode, otherEntity.statusCode);
}
@Override
public int hashCode() {
return (super.hashCode() * 29 + ObjectUtils.nullSafeHashCode(this.statusCode));
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder("<");
builder.append(this.statusCode.toString());
builder.append(' ');
builder.append(this.statusCode.getReasonPhrase());
builder.append(',');
T body = getBody();
HttpHeaders headers = getHeaders();
if (body != null) {
builder.append(body);
if (headers != null) {
builder.append(',');
}
}
if (headers != null) {
builder.append(headers);
}
builder.append('>');
return builder.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy