当前位置:网站首页>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;
}
边栏推荐
- Intel introduces you to visual recognition -- openvino
- [search] - iteration deepening / bidirectional dfs/ida*
- ELMO,BERT和GPT简介
- 全面升级,淘宝/天猫api接口大全
- Teach you a text to solve the problem of JS digital accuracy loss
- CSDN modify column name
- How many of the top ten test tools in 2022 do you master
- golang启动报错【已解决】
- 【golang】使用select {}
- 【HCIP】两个MGRE网络通过OSPF实现互联(eNSP)
猜你喜欢

Matplotlib Chinese question

一文读懂Okaleido Tiger近期动态,挖掘背后价值与潜力

ELMO,BERT和GPT简介

【Web技术】1395- Esbuild Bundler HMR

T-sne dimensionality reduction

SQL question brushing: find the current salary details and department number Dept_ no

body中基本标签

BOM系列之window对象

Lombook User Guide

After understanding the composition of the URL of the website, we use the URL module, querystring module and mime module to improve the static website
随机推荐
SiC功率半导体产业高峰论坛成功举办
C语言犄角旮旯的知识之形参、实参、main函数参数、数组或指针做函数参数等
PCL point cloud intensity image
JS事件简介
Merkel Studio - harmonyos implementation list to do
【GoLang】网络连接 net.Dial
Analysys analysis: focus on users, improve the user experience of mobile banking, and help the growth of user value
RHCE command practice (II)
[hcip] MPLS Foundation
Digital currency of quantitative transactions - generate foot print factor data
采用QT进行OpenGL开发(二)绘制立方体
golang启动报错【已解决】
T-sne降维
Flash reports an error: type object 'news' has no attribute' query 'the view name is duplicate with the model name
新生代公链再攻「不可能三角」
数据库的decimal类型的数据,发现可以通过resultSet.getDouble去拿到这个数据,但是通过getObject却拿不到这个属性。
Understand various paths
围绕新市民金融聚焦差异化产品设计、智能技术提效及素养教育
TypeError: can only concatenate str (not “int“) to str
Code generator