com.heroku.api.request.RequestTransformation Maven / Gradle / Ivy
package com.heroku.api.request;
import com.heroku.api.http.Http;
import java.util.Map;
/**
* Transforms a {@link Request}<A>
into a {@link Request}<B>
* to allow parsing of the raw response to create a B
.
*
* This is useful for extending standard request classes with a different response type.
*
* @author Ryan Brainard
*/
public abstract class RequestTransformation implements Request {
private final Request a;
public RequestTransformation(Request a) {
this.a = a;
}
@Override
public Http.Method getHttpMethod() {
return a.getHttpMethod();
}
@Override
public String getEndpoint() {
return a.getEndpoint();
}
@Override
public boolean hasBody() {
return a.hasBody();
}
@Override
public String getBody() {
return a.getBody();
}
@Override
public Map getBodyAsMap() {
return a.getBodyAsMap();
}
@Override
public Http.Accept getResponseType() {
return a.getResponseType();
}
@Override
public Map getHeaders() {
return a.getHeaders();
}
@Override
public abstract B getResponse(byte[] bytes, int status, Map responseHeaders);
}