All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.heroku.api.request.RequestTransformation Maven / Gradle / Ivy

There is a newer version: 0.46
Show newest version
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);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy