T - The Type of the Entity that will be embedded in the API Response.public class ApiResponse<T> extends Object
| Constructor and Description |
|---|
ApiResponse() |
| Modifier and Type | Method and Description |
|---|---|
static <T> ApiResponse<T> |
error(String message,
int status) |
static <T> ApiResponse<T> |
fail(String message) |
static <T> ApiResponse<T> |
fromOptional(Optional<T> optionalData)
Returns the value of the Optional if it exists, otherwise throws a "404 Not Found" exception
|
T |
getData() |
ApiError |
getError() |
ApiResponseStatus |
getStatus() |
void |
setData(T data) |
void |
setError(ApiError error) |
void |
setStatus(ApiResponseStatus status) |
static <T> ApiResponse<T> |
success(T data) |
String |
toString() |
public ApiResponseStatus getStatus()
public void setStatus(ApiResponseStatus status)
public T getData()
public void setData(T data)
public ApiError getError()
public void setError(ApiError error)
public static <T> ApiResponse<T> fromOptional(Optional<T> optionalData) throws NotFoundException
T - The Type of the OptionaloptionalData - An Optional who's contents we want to returnNotFoundException - if Optional is emptypublic static <T> ApiResponse<T> success(T data)
public static <T> ApiResponse<T> error(String message, int status)
public static <T> ApiResponse<T> fail(String message)
Copyright © 2019. All rights reserved.