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

com.cloudesire.platform.apiclient.response.CallResponse Maven / Gradle / Ivy

package com.cloudesire.platform.apiclient.response;

import java.util.List;
import java.util.Map;

public class CallResponse
{
    private final int code;
    private final Map> headers;
    private final T body;
    private final Pagination paginator;

    public CallResponse( int code, T body, Map> headers )
    {
        this.code = code;
        this.body = body;
        this.headers = headers;
        this.paginator = new Pagination( headers );
    }

    public int getCode()
    {
        return code;
    }

    public T getBody()
    {
        return body;
    }

    public String getHeader( String name )
    {
        List values = headers.get( name );
        if ( values == null ) return null;
        if ( values.size() == 1 ) return values.get( 0 );
        throw new IllegalArgumentException( "Multiple values" );
    }

    public Map> getAllHeaders()
    {
        return headers;
    }

    public Pagination paginator()
    {
        return paginator;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy