io.katharsis.errorhandling.ErrorResponse Maven / Gradle / Ivy
package io.katharsis.errorhandling;
import io.katharsis.queryParams.QueryParams;
import io.katharsis.request.path.JsonPath;
import io.katharsis.response.BaseResponseContext;
import io.katharsis.response.JsonApiResponse;
import java.util.Objects;
public final class ErrorResponse implements BaseResponseContext {
public static final String ERRORS = "errors";
private final Iterable data;
private final int httpStatus;
public ErrorResponse(Iterable data, int httpStatus) {
this.data = data;
this.httpStatus = httpStatus;
}
@Override
public int getHttpStatus() {
return httpStatus;
}
@Override
public JsonApiResponse getResponse() {
return new JsonApiResponse()
.setEntity(data);
}
@Override
public JsonPath getJsonPath() {
return null;
}
@Override
public QueryParams getQueryParams() {
return null;
}
public static ErrorResponseBuilder builder() {
return new ErrorResponseBuilder();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ErrorResponse)) {
return false;
}
ErrorResponse that = (ErrorResponse) o;
return Objects.equals(httpStatus, that.httpStatus) &&
Objects.equals(data, that.data);
}
@Override
public int hashCode() {
return Objects.hash(data, httpStatus);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy