当前位置:网站首页>Internship: tool class writing for type judgment
Internship: tool class writing for type judgment
2022-07-29 01:43:00 【ahyo】
Integrate most of the data types that need to be judged into a tool class , Just call the method directly ;
/** * Is the object not empty */
public static boolean isNotEmpty(Object o) {
return !isEmpty(o);
}
/** * Whether the object is empty */
@SuppressWarnings("rawtypes")
public static boolean isEmpty(Object o) {
if (o == null) {
return true;
}
if (o instanceof String) {
if (o.toString().trim().equals("")) {
return true;
}
} else if (o instanceof List) {
if (((List) o).size() == 0) {
return true;
}
} else if (o instanceof Map) {
if (((Map) o).size() == 0) {
return true;
}
} else if (o instanceof Set) {
if (((Set) o).size() == 0) {
return true;
}
} else if (o instanceof Object[]) {
if (((Object[]) o).length == 0) {
return true;
}
} else if (o instanceof int[]) {
if (((int[]) o).length == 0) {
return true;
}
} else if (o instanceof long[]) {
if (((long[]) o).length == 0) {
return true;
}
}
return false;
}
/** * Whether there is an empty object */
public static boolean isOneEmpty(Object... objects){
for (Object object : objects) {
boolean empty = isEmpty(object);
if(empty){
return true;
}
}
return false;
}
/** * map turn list * @param map * @return */
public static List mapTransitionList(Map map) {
List list = new ArrayList();
Iterator iter = map.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
list.add(entry.getKey());
list.add(entry.getValue());
}
return list;
}
边栏推荐
- 拼多多众多 API 接口皆可使用
- SQL question brushing: find the last of all employees_ Name and first_ Name and corresponding department number Dept_ no
- Redis installation, cluster deployment and common tuning
- Moonbeam上的多链用例解析——Derek在Polkadot Decoded 2022的演讲文字回顾
- matplotlib中文问题
- Teach you a text to solve the problem of JS digital accuracy loss
- 【HCIP】重发布及路由策略的实验
- [SQL's 18 dragon subduing palms] 01 - Kang long regrets: introductory 10 questions
- T-sne降维
- [hcip] MPLS Foundation
猜你喜欢

承办首届算力大会,济南胜在何处?

Basic label in body

2022年最火的十大测试工具,你掌握了几个

PLATO上线LAAS协议Elephant Swap,用户可借此获得溢价收益

Openpyxl border

Analysis of Multi Chain use cases on moonbeam -- review of Derek's speech in Polkadot decoded 2022

T-sne dimensionality reduction

Embedded sharing collection 23

Cloud native application comprehensive exercise

Matplotlib Chinese question
随机推荐
HCIA配置实例(eNSP)
明日无限计划,2022某公司元宇宙产品发布会活动概念策划方案
The new generation of public chain attacks the "Impossible Triangle"
【HCIP】MGRE环境下OSPF实验,含多进程双向重发布及OSPF特殊区域
Django uses pymysql module to connect mysql database
【GoLang】网络连接 net.Dial
如何选择专业、安全、高性能的远程控制软件
采用QT进行OpenGL开发(二)绘制立方体
C language 300 lines of code to achieve mine sweeping (deployable + markable + changeable difficulty level)
Docker-compose安装mysql
活动速递| Apache Doris 性能优化实战系列直播课程初公开,诚邀您来参加!
【HCIP】重发布及路由策略的实验
Autoware reports an error: can't generate global path for start solution
T-sne降维
云原生应用综合练习下
过去10年的10起重大网络安全事件
Merkel Studio - harmonyos implementation list to do
Understand all the basic grammar of ES6 in one article
【Web技术】1395- Esbuild Bundler HMR
PLATO上线LAAS协议Elephant Swap,用户可借此获得溢价收益