com.sap.cloud.rest.api.client.model.HttpExchangeContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rest-api-client Show documentation
Show all versions of rest-api-client Show documentation
Java HTTP client library for HTTP handling, when building clients for RESTful APIs.
The newest version!
package com.sap.cloud.rest.api.client.model;
import static com.sap.cloud.rest.api.client.utils.ValidateArgument.isNotNull;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* Represents the context in which the exception was thrown, e.g the request
* that was made and the response received.
*
*/
public class HttpExchangeContext {
static final String REQUEST_DISPLAY_NAME = "Request";
static final String RESPONSE_DISPLAY_NAME = "Response";
private final Request request;
private final Response response;
public HttpExchangeContext(final Request request, final Response response) {
isNotNull(REQUEST_DISPLAY_NAME, request);
isNotNull(RESPONSE_DISPLAY_NAME, response);
this.request = request;
this.response = response;
}
public Request getRequest() {
return request;
}
public Response getResponse() {
return response;
}
public String toString() {
return new ToStringBuilder(HttpExchangeContext.class.getName(), ToStringStyle.JSON_STYLE)
.append("request", request)
.append("response", response)
.toString();
}
}