惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threat Research - Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
V
Vulnerabilities – Threatpost
GbyAI
GbyAI
P
Proofpoint News Feed
L
LINUX DO - 热门话题
P
Palo Alto Networks Blog
A
About on SuperTechFans
T
Tenable Blog
M
MIT News - Artificial intelligence
IT之家
IT之家
I
Intezer
D
DataBreaches.Net
爱范儿
爱范儿
T
Threatpost
C
CERT Recently Published Vulnerability Notes
云风的 BLOG
云风的 BLOG
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
K
Kaspersky official blog
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Y
Y Combinator Blog
Cyberwarzone
Cyberwarzone
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Darknet – Hacking Tools, Hacker News & Cyber Security
H
Help Net Security
Microsoft Security Blog
Microsoft Security Blog
Spread Privacy
Spread Privacy
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
AWS News Blog
AWS News Blog
博客园 - 聂微东
C
Check Point Blog
S
Securelist
有赞技术团队
有赞技术团队
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
Last Week in AI
Last Week in AI
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
D
Docker
G
GRAHAM CLULEY
T
The Exploit Database - CXSecurity.com
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tailwind CSS Blog
L
Lohrmann on Cybersecurity
G
Google Developers Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog

博客园 - 西就东城

阅读《Design pattern》-观察者模式 ubuntu实践静态IP以及远程桌面 ubuntu安装备忘录 Apk应用框架Collie-003.Gson Apk应用框架Collie-002.Logger Apk应用框架Collie-001.LeakCanary Android应用程序框架-Collie 阅读的路上 关于阅读 接触软件体系架构设计(八) 接触软件体系架构设计(七) 接触软件体系架构设计(六) 接触软件体系架构设计(五) 接触软件体系架构设计(四) 接触软件体系架构设计(三) 接触软件体系架构设计(二) 接触软件体系架构设计(一) 概念集中梳理区 H公司以及我的目标 - 西就东城
Apk应用框架Collie-004.bean层
西就东城 · 2020-08-27 · via 博客园 - 西就东城

基于Gson上,搭建bean层

上码:

 1 /**
 2  * @author 黄宗旭
 3  * @version 20.08.27
 4  */
 5 public interface IJson {
 6     /**
 7      * 从json进行转换
 8      * @param json json串 ,非空
 9      * @return 转换成功标记
10      */
11     boolean fromJson(String json);
12 
13     /**
14      * 对象转为json
15      * @return json串
16      */
17     String toJson();
18 }
 1 /**
 2  * 基础bean类
 3  *
 4  * @author 黄宗旭
 5  * @version 20.08.27
 6  */
 7 public class BaseBean implements IJson {
 8 
 9     @Override
10     public boolean fromJson(String json) {
11         return false;
12     }
13 
14     @Override
15     public String toJson() {
16         return GsonHelper.getInstance().toJson(this);
17     }
18 }

这里可见GsonHelper的使用地方

另外再贴:

 1 /**
 2  * 响应结果结构
 3  *
 4  * @author 黄宗旭
 5  * @version 20.08.27
 6  */
 7 public class ResponseResult extends BaseBean {
 8     @SerializedName("ErrorCode")
 9     private Integer errorCode;
10     @SerializedName("ErrorMsg")
11     private String errorMsg;
12     @SerializedName("Data")
13     private Object data;
14 
15     /**
16      * Instantiates a new Response result.
17      */
18     public ResponseResult() {
19         this.errorCode = 0;
20         this.errorMsg = "";
21         this.data = null;
22     }
23 
24     /**
25      * 拷贝函数
26      *
27      * @param source 数据源
28      */
29     public void copy(ResponseResult source) {
30         if (source != null) {
31             this.errorCode = source.errorCode;
32             this.errorMsg = source.errorMsg;
33             this.data = source.data;
34         }
35     }
36 
37 
38     /**
39      * Gets error code.
40      *
41      * @return the error code
42      */
43     public Integer getErrorCode() {
44         return errorCode;
45     }
46 
47     public void setErrorCode(Integer errorCode) {
48         this.errorCode = errorCode;
49     }
50 
51     /**
52      * Gets error msg.
53      *
54      * @return the error msg
55      */
56     public String getErrorMsg() {
57         return errorMsg;
58     }
59 
60     /**
61      * Sets error msg.
62      *
63      * @param errorMsg the error msg
64      */
65     public void setErrorMsg(String errorMsg) {
66         this.errorMsg = errorMsg;
67     }
68 
69     /**
70      * Gets data.
71      *
72      * @return the data
73      */
74     public Object getData() {
75         return data;
76     }
77 
78     /**
79      * Sets data.
80      *
81      * @param data the data
82      */
83     public void setData(Object data) {
84         this.data = data;
85     }
86 
87     @Override
88     public boolean fromJson(String json) {
89         boolean isSuccess = false;
90         if (json != null && json.length() > 0) {
91             ResponseResult bean = GsonHelper.getInstance().fromJson(json, ResponseResult.class);
92             copy(bean);
93             isSuccess = true;
94         }
95 
96         return isSuccess;
97     }
98 }

bean的使用就不多说了吧,bean肯定还有不断补充,也是被db或biz或ui使用