Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Flying9001
Demo
Repository navigation
Code
Issues
Pull requests
6
(6)
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
Demo
/
src
/
main
/
java
/
com
/
ljq
/
demo
/
bean
/
JavaBeanDemo.java
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
50 lines (42 loc) · 1.53 KB
master
Breadcrumbs
Demo
/
src
/
main
/
java
/
com
/
ljq
/
demo
/
bean
/
JavaBeanDemo.java
Copy path
Top
File metadata and controls
Code
Blame
50 lines (42 loc) · 1.53 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.ljq.demo.bean;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
/**
* @Description: java bean demo/java bean 的示范类
* @Author: junqiang.lu
* @Date: 2018/6/21
*/
/**
* 通过引入 lombok 包,在java bean 类上边使用 @Setter,@Getter,@ToString 注解
* 即可实现 setter,getter,和 toString 的方法,无需再自己手写,以精简代码
*/
@Setter
@Getter
@ToString
/**
* 实现 Serializable 接口,实现序列化
*/
public class JavaBeanDemo implements Serializable {
/**
* 定义 serialVersionUID,确保序列化与反序列化的过程中,属性值不变
*/
private static final long serialVersionUID = 4833136009765814333L;
private String username;
/**
* 引入 jackson 包,用于处理 json 数据转换
* 使用 @JsonIgnore 注解,java 对象在转化为 json 对象时可以忽略此字段
* 在 java 实体类(entity)中,有些字段在做 json 转换时是不需要的,则可以使用该注解
*/
@JsonIgnore
private String passcode;
/**
* 对于 boolean 类型的字段,不要以 is 开头,eg: isPay
* 因为 boolean 类型的字段的 getter 方法以 is 开头的,而非 get
* 如果字段也是以 is 开头,则会被忽略掉本身的 is,
* 在客户端通过接口进行传值时会引起后台获取不到对应值或 json 转换失败等问题
*/
private boolean ifVIP;
}
You can’t perform that action at this time.