com.cybermkd.common.http.result.WebResult Maven / Gradle / Ivy
package com.cybermkd.common.http.result;
import java.util.Map;
/**
* Created by ice on 14-12-19.
* A WebResult can be raised to make ICEREST return immediately an HTTP response with a specific HTTP status.
*/
public class WebResult {
private final HttpStatus status;
private final T result;
private final Map headers;
public WebResult(HttpStatus status) {
this(status, null, null);
}
public WebResult(HttpStatus status, Map headers) {
this(status, null, headers);
}
public WebResult(T result) {
this(HttpStatus.OK, result, null);
}
public WebResult(T result, Map headers) {
this(HttpStatus.OK, result, headers);
}
public WebResult(HttpStatus status, T result) {
this(status, result, null);
}
public WebResult(HttpStatus status, T result, Map headers) {
this.status = status;
this.result = result;
this.headers = headers;
}
public HttpStatus getStatus() {
return status;
}
/**
* Returns the content to use in the HTTP response .
*
* @return the content to use in the response.
*/
public T getResult() {
return result;
}
public Map getHeaders() {
return headers;
}
}