001package com.identityworksllc.iiq.common.plugin;
002
003/**
004 * A meta-object that can be returned by a handle() implementation to specify both
005 * a return object and a status in the return value. This should prevent implementers
006 * from needing to return a Response in most cases.
007 *
008 * @param <T> The type of the wrapped object
009 */
010public class ErrorResponse<T> {
011    /**
012     * The response code to use
013     */
014    private final int responseCode;
015
016    /**
017     * The wrapped object, which must be serializable by JAX-RS
018     */
019    private final T wrappedObject;
020
021    /**
022     * Constructs a new error response wrapper object
023     *
024     * @param responseCode The response code to return to the REST client
025     * @param wrappedObject The object to return to the REST client
026     */
027    public ErrorResponse(int responseCode, T wrappedObject) {
028        this.responseCode = responseCode;
029        this.wrappedObject = wrappedObject;
030    }
031
032    /**
033     * Gets the response code for this error response
034     * @return The response code
035     */
036    public int getResponseCode() {
037        return responseCode;
038    }
039
040    /**
041     * Gets the wrapped object for this error response
042     * @return The wrapped object
043     */
044    public T getWrappedObject() {
045        return wrappedObject;
046    }
047}