Package com.fasterxml.clustermate.client.ahc

Source Code of com.fasterxml.clustermate.client.ahc.AHCGetCallResult

package com.fasterxml.clustermate.client.ahc;

import com.fasterxml.clustermate.client.CallFailure;
import com.fasterxml.clustermate.client.call.GetCallResult;
import com.ning.http.client.HttpResponseHeaders;

/**
* Container for results of a single GET call to a server node.
* Note that at most one of '_fail' and '_result' can be non-null; however,
* it is possible for both to be null: this occurs in cases where
* communication to server(s) succeeds, but no content was found
* (either 404, or deleted content).
*/
public final class AHCGetCallResult<T> extends GetCallResult<T>
{
    protected HttpResponseHeaders _headers;

    /*
    /**********************************************************************
    /* Construction, initialization
    /**********************************************************************
     */
   
    public AHCGetCallResult(int status, T result) {
        super(status, result);
    }

    public AHCGetCallResult(CallFailure fail) {
        super(fail);
    }

    public static <T> AHCGetCallResult<T> notFound() {
        return new AHCGetCallResult<T>(404, null);
    }

    public void setHeaders(HttpResponseHeaders h) {
        _headers = h;
    }

    /*
    /**********************************************************************
    /* Accessors
    /**********************************************************************
     */

    @Override
    public String getHeaderValue(String key)
    {
        HttpResponseHeaders h = _headers;
        return (h == null) ? null : h.getHeaders().getFirstValue(key);
    }
}
TOP

Related Classes of com.fasterxml.clustermate.client.ahc.AHCGetCallResult

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.