public class HttpWrapper<T> extends CloneSupport<HttpWrapper<T>> implements Wrapper<T>, ILogObject, IMapObject<String,Object>
Modifier and Type | Field and Description |
---|---|
static Integer |
HTTP_ERROR_CODE |
static String |
HTTP_ERROR_MESSAGE |
static Integer |
HTTP_OK_CODE |
static String |
HTTP_OK_MESSAGE |
Constructor and Description |
---|
HttpWrapper() |
HttpWrapper(CodeInfo info) |
HttpWrapper(CodeInfo info,
T data) |
HttpWrapper(int code) |
HttpWrapper(int code,
String msg) |
HttpWrapper(int code,
String msg,
T data) |
Modifier and Type | Method and Description |
---|---|
HttpWrapper<T> |
code(int code) |
HttpWrapper<T> |
data(T data) |
static <T> HttpWrapper<T> |
error()
失败
|
static <T> HttpWrapper<T> |
error(String msg) |
static <T> HttpWrapper<T> |
error(String msg,
Object... params) |
static <T> HttpWrapper<T> |
error(Throwable t) |
static <T> HttpWrapper<T> |
get()
初始化
|
int |
getCode() |
T |
getData() |
String |
getMsg() |
boolean |
isOk()
是否为成功状态码
|
<E> HttpWrapper<E> |
map(Function<T,E> mapping)
映射
|
HttpWrapper<T> |
msg(String msg) |
static <T> HttpWrapper<T> |
of(CodeInfo info)
定义
|
static <T> HttpWrapper<T> |
of(CodeInfo info,
T data) |
static <T> HttpWrapper<T> |
of(int code,
String msg) |
static <T> HttpWrapper<T> |
of(int code,
String msg,
T data) |
static <T> HttpWrapper<T> |
ok()
成功
|
static <T> HttpWrapper<T> |
ok(T data) |
Optional<T> |
optional() |
void |
setCode(int code) |
void |
setData(T data) |
void |
setMsg(String msg) |
String |
toLogString()
转为日志
|
Map<String,Object> |
toMap()
转为 map
|
RpcWrapper<T> |
toRpcWrapper() |
String |
toString() |
clone
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
toJsonString
asMap
public static final Integer HTTP_OK_CODE
public static final String HTTP_OK_MESSAGE
public static final Integer HTTP_ERROR_CODE
public static final String HTTP_ERROR_MESSAGE
public HttpWrapper()
public HttpWrapper(int code)
public HttpWrapper(int code, String msg)
public HttpWrapper(CodeInfo info)
public static <T> HttpWrapper<T> get()
public static <T> HttpWrapper<T> of(CodeInfo info)
public static <T> HttpWrapper<T> of(CodeInfo info, T data)
public static <T> HttpWrapper<T> of(int code, String msg)
public static <T> HttpWrapper<T> of(int code, String msg, T data)
public static <T> HttpWrapper<T> ok()
public static <T> HttpWrapper<T> ok(T data)
public static <T> HttpWrapper<T> error()
public static <T> HttpWrapper<T> error(String msg)
public static <T> HttpWrapper<T> error(String msg, Object... params)
public static <T> HttpWrapper<T> error(Throwable t)
public HttpWrapper<T> code(int code)
public HttpWrapper<T> msg(String msg)
public HttpWrapper<T> data(T data)
public void setCode(int code)
public void setMsg(String msg)
public void setData(T data)
public int getCode()
public String getMsg()
public T getData()
public boolean isOk()
public String toLogString()
ILogObject
toLogString
in interface ILogObject
public Map<String,Object> toMap()
IMapObject
toMap
in interface IMapObject<String,Object>
public <E> HttpWrapper<E> map(Function<T,E> mapping)
E
- Emapping
- mappingpublic RpcWrapper<T> toRpcWrapper()
RpcWrapper
Copyright © 2024. All rights reserved.