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

com.facebook.airlift.http.client.thrift.ThriftResponse Maven / Gradle / Ivy

The newest version!
package com.facebook.airlift.http.client.thrift;

import com.facebook.airlift.http.client.HeaderName;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ListMultimap;

import javax.annotation.Nullable;

import java.util.List;

public class ThriftResponse
{
    private final int statusCode;
    private final String errorMessage;
    private final ListMultimap headers;
    private final T value;
    private final IllegalArgumentException exception;

    ThriftResponse(
            int statusCode,
            String errorMessage,
            ListMultimap headers,
            T value,
            IllegalArgumentException exception)
    {
        this.statusCode = statusCode;
        this.errorMessage = errorMessage;
        this.headers = headers != null ? ImmutableListMultimap.copyOf(headers) : null;
        this.value = value;
        this.exception = exception;
    }

    public int getStatusCode()
    {
        return statusCode;
    }

    public String getErrorMessage()
    {
        return errorMessage;
    }

    public T getValue()
    {
        return value;
    }

    @Nullable
    public String getHeader(String name)
    {
        List values = getHeaders().get(HeaderName.of(name));
        return values.isEmpty() ? null : values.get(0);
    }

    public List getHeaders(String name)
    {
        return headers.get(HeaderName.of(name));
    }

    public ListMultimap getHeaders()
    {
        return headers;
    }

    public IllegalArgumentException getException()
    {
        return exception;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy