net.paissad.minus.api.MinusHttpResponse.java Source code

Java tutorial

Introduction

Here is the source code for net.paissad.minus.api.MinusHttpResponse.java

Source

/*
 * This file is part of Minus-Java.
 * 
 * Minus-Java is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Minus-Java is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with Minus-Java. If not, see <http://www.gnu.org/licenses/>.
 */

package net.paissad.minus.api;

import java.io.Serializable;

import org.apache.http.cookie.Cookie;

import net.paissad.minus.annotation.Immutable;

/**
 * Represents a class which holds a HTTP response from a HTTP request (GET or
 * POST) and the {@link Cookie} which was returned by the server during the HTTP
 * request.
 * <p>
 * <b>Note</b>: This class is immutable and is aimed to be used internally, and
 * not by end users of the library.
 * </p>
 * 
 * @author Papa Issa DIAKHATE (paissad)
 * 
 */
@Immutable
public final class MinusHttpResponse implements Serializable, Cloneable {

    private static final long serialVersionUID = 1L;

    private final Object httpResponse;
    private final Cookie cookie;

    public MinusHttpResponse(final Object httpResponse, final Cookie cookie) {
        this.httpResponse = httpResponse;
        this.cookie = cookie;
    }

    public Object getHttpResponse() {
        return httpResponse;
    }

    public Cookie getCookie() {
        return cookie;
    }

    public String getSessionId() {
        return (getCookie() != null) ? getCookie().getValue() : null;
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}