当前位置:网站首页>Response < t > class
Response < t > class
2022-07-28 05:28:00 【MusicCodeM】
Project scenario :
Now the data returned by the development backend to the front end is json data , So use the following tool class , Make a note of . Convenient for future use .Solution :
Tips : Fill in the specific solution to the problem here :
utils:
Response.java
public class Response<T> {
private Boolean success;
private String message;
private T data;
public Response() {
}
public Response(Boolean success) {
this.success = success;
}
public Response(Boolean success, String message) {
this.success = success;
this.message = message;
}
public Response(Boolean success, String message, T data) {
this.success = success;
this.message = message;
this.data = data;
}
public static <T> Response<T> yes() {
return new Response(true, " Successful operation ");
}
public static <T> Response<T> yes(String message,T data) {
return new Response(true, message, data);
}
public static <T> Response<T> yes(T data) {
return new Response(true, " Successful operation ", data);
}
public static <T> Response<T> no() {
return new Response(false, " operation failed ");
}
public static <T> Response<T> no(String message) {
return new Response(false, message);
}
public Boolean isSuccess() {
return success;
}
public void setSuccess(Boolean success) {
this.success = success;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}
边栏推荐
- Scope, execution process and life cycle of bean
- Share several methods of managing flag bits in C program
- How should programmers keep warm when winter is coming
- First acquaintance with C language (2)
- regular expression
- PC side bug record
- 【ARXIV2204】Simple Baselines for Image Restoration
- 2022 summer practice (PowerDesigner tutorial learning record) (first week)
- About MySQL group_ What concat has to say
- block yandex bot
猜你喜欢

Configuration experiment of building virtual private network based on MPLS

数据库日期类型全部为0

How about ink cloud?

微服务故障模式与构建弹性系统

【CVPR2022 oral】Balanced Multimodal Learning via On-the-fly Gradient Modulation

First acquaintance with C language (1)
![[internal mental skill] - creation and destruction of function stack frame (C implementation)](/img/a9/81644ee9ffb74a5dc8ff1bc3977f49.png)
[internal mental skill] - creation and destruction of function stack frame (C implementation)

Tomato timing dimming table lamp touch chip-dlt8t10s-jericho
![[computer level 3 information security] overview of information security assurance](/img/f0/a72e61fda58ea93ca4e9db7274f6e3.png)
[computer level 3 information security] overview of information security assurance

Eccv2022 | 29 papers of Tencent Youtu were selected, including face security, image segmentation, target detection and other research directions
随机推荐
Long和Integer如何进行比较,为什么报错
How does Alibaba use DDD to split microservices?
repackag failed: Unable to find main class
PC side bug record
php7.1 连接sqlserver2008r2 如何测试成功
【ARIXV2204】Neighborhood attention transformer
Struct模块到底有多实用?一个知识点立马学习
11. < tag dynamic programming and subsequence, subarray> lt.115. Different subsequences + Lt. 583. Deletion of two strings DBC
2021CSDN博客之星评选,互投
Have you ever seen this kind of dynamic programming -- the stock problem of state machine dynamic programming (Part 2)
2022 summer practice (PowerDesigner tutorial learning record) (first week)
New methods and features of ES6 built-in objects
Eccv2022 | 29 papers of Tencent Youtu were selected, including face security, image segmentation, target detection and other research directions
The solution after the samesite by default cookies of Chrome browser 91 version are removed, and the solution that cross domain post requests in chrome cannot carry cookies
Message forwarding mechanism -- save your program from crashing
Mysql基本查询
项目中问题合集
mysql的日期与时间函数,varchar与date相互转换
PC端-bug记录
数据库面试