Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
勤为径苦作舟
ZUtil
提交
057fe923
Z
ZUtil
项目概览
勤为径苦作舟
/
ZUtil
10 个月 前同步成功
通知
6
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
ZUtil
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
057fe923
编写于
2月 11, 2023
作者:
勤为径苦作舟
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 修复 CollectionUtils 错误并完善覆盖率测试
上级
6f0ebe70
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
209 addition
and
75 deletion
+209
-75
src/main/java/top/csaf/CollectionUtils.java
src/main/java/top/csaf/CollectionUtils.java
+53
-51
src/test/java/top/csaf/junit/CollectionUtilsTest.java
src/test/java/top/csaf/junit/CollectionUtilsTest.java
+156
-24
未找到文件。
src/main/java/top/csaf/CollectionUtils.java
浏览文件 @
057fe923
...
...
@@ -128,10 +128,10 @@ public class CollectionUtils {
}
/**
* 是否
集合不为 null 且
有元素
* 是否
不满足 集合为 null 或 没
有元素
*
* @param coll 集合
* @return 是否
集合不为 null 且
有元素
* @return 是否
不满足 集合为 null 或 没
有元素
*/
public
static
boolean
isNotEmpty
(
java
.
util
.
Collection
<?>
coll
)
{
return
org
.
apache
.
commons
.
collections4
.
CollectionUtils
.
isNotEmpty
(
coll
);
...
...
@@ -251,7 +251,7 @@ public class CollectionUtils {
/**
* 是否 每个集合
都 (为 null 或 没有元素)
* 是否 每个集合
都为 null 或 没有元素
*
* @param colls 多个集合,只传一个数组请调用 {@link #isEmpty(Collection)}
* @return 是否 每个集合都 (为 null 或 没有元素)
...
...
@@ -262,8 +262,8 @@ public class CollectionUtils {
}
for
(
Collection
<?>
coll
:
colls
)
{
// 如果 某个集合
(不为 null 且 有元素)
if
(
isEmpty
(
coll
))
{
// 如果 某个集合
不为 null 且 有元素
if
(
!
isEmpty
(
coll
))
{
return
false
;
}
}
...
...
@@ -271,27 +271,27 @@ public class CollectionUtils {
}
/**
* 是否
每个集合都 (不为 null 且 有元素)
* 是否
不满足 每个集合 都为 null 或 没有元素
*
* @param colls 多个集合,只传一个数组请调用 {@link #isNotEmpty(Collection)}
* @return 是否
每个集合都 (不为 null 且 有元素)
* @return 是否
不满足 每个集合 都为 null 或 没有元素
*/
public
static
boolean
isNotEmptys
(
final
Collection
<?>...
colls
)
{
public
static
boolean
isNotEmptys
(
@NonNull
final
Collection
<?>...
colls
)
{
return
!
isEmptys
(
colls
);
}
/**
* 是否
对象不为 null 且
有元素
* 是否
不满足 对象为 null 或 没
有元素
*
* @param object 对象
* @return 是否
对象不为 null 且
有元素
* @return 是否
不满足 对象为 null 或 没
有元素
*/
public
static
boolean
sizeIsNotEmpty
(
@NonNull
final
Object
object
)
{
return
!
sizeIsEmpty
(
object
);
}
/**
* 是否 每个对象
都 (为 null 或 没有元素)
* 是否 每个对象
都为 null 或 没有元素
*
* <ul>
* <li>Collection - via collection isEmpty
...
...
@@ -302,16 +302,16 @@ public class CollectionUtils {
* </ul>
*
* @param objects 多个对象。只传一个数组请调用 {@link #sizeIsEmpty(Object)}
* @return 是否 每个对象
都 (为 null 或 没有元素)
* @return 是否 每个对象
都为 null 或 没有元素
*/
public
static
boolean
sizeIsEmptys
(
final
Object
...
objects
)
{
public
static
boolean
sizeIsEmptys
(
@NonNull
final
Object
...
objects
)
{
if
(
objects
.
length
<
2
)
{
throw
new
IllegalArgumentException
(
"Objects: length must be greater than 1."
);
}
for
(
Object
object
:
objects
)
{
// 如果 某个对象
(不为 null 且 有元素)
if
(
sizeIsEmpty
(
object
))
{
// 如果 某个对象
不为 null 且 有元素
if
(
!
sizeIsEmpty
(
object
))
{
return
false
;
}
}
...
...
@@ -319,10 +319,10 @@ public class CollectionUtils {
}
/**
* 是否
每个对象都 (不为 null 且 有元素)
* 是否
不满足 每个对象 都为 null 或 没有元素
*
* @param objects 多个对象。只传一个数组请调用 {@link #sizeIsNotEmpty(Object)}
* @return 是否
每个对象都 (不为 null 且 有元素)
* @return 是否
不满足 每个对象 都为 null 或 没有元素
*/
public
static
boolean
sizeIsNotEmptys
(
@NonNull
final
Object
...
objects
)
{
return
!
sizeIsEmptys
(
objects
);
...
...
@@ -342,27 +342,18 @@ public class CollectionUtils {
* </ul>
*
* @param object 对象
* @return 是否 对象所有元素都为 null 或 没有元素
)
* @return 是否 对象所有元素都为 null 或 没有元素
*/
public
static
boolean
isAllEmpty
(
final
Object
object
)
{
if
(
object
==
null
)
{
if
(
sizeIsEmpty
(
object
)
)
{
return
true
;
}
if
(
object
instanceof
Collection
)
{
Collection
<?>
obj1
=
(
Collection
<?>)
object
;
obj1
.
removeIf
(
Objects:
:
isNull
);
return
obj1
.
size
()
==
0
;
}
else
if
(
object
instanceof
Iterable
<?>)
{
if
(
object
instanceof
Iterable
<?>)
{
for
(
Object
o
:
(
Iterable
<?>)
object
)
{
if
(
o
!=
null
)
{
return
false
;
}
}
}
else
if
(
object
instanceof
Map
<?,
?>)
{
return
isAllEmptys
(((
Map
<?,
?>)
object
).
values
());
}
else
if
(
object
instanceof
Object
[])
{
Object
[]
obj1
=
(
Object
[])
object
;
return
Arrays
.
stream
(
obj1
).
noneMatch
(
Objects:
:
nonNull
);
}
else
if
(
object
instanceof
Iterator
<?>)
{
Iterator
<?>
obj1
=
(
Iterator
<?>)
object
;
while
(
obj1
.
hasNext
())
{
...
...
@@ -370,6 +361,11 @@ public class CollectionUtils {
return
false
;
}
}
}
else
if
(
object
instanceof
Map
<?,
?>)
{
return
isAllEmpty
(((
Map
<?,
?>)
object
).
values
());
}
else
if
(
object
instanceof
Object
[])
{
Object
[]
obj1
=
(
Object
[])
object
;
return
Arrays
.
stream
(
obj1
).
noneMatch
(
Objects:
:
nonNull
);
}
else
if
(
object
instanceof
Enumeration
<?>)
{
Enumeration
<?>
obj1
=
(
Enumeration
<?>)
object
;
while
(
obj1
.
hasMoreElements
())
{
...
...
@@ -377,22 +373,24 @@ public class CollectionUtils {
return
false
;
}
}
}
else
{
throw
new
IllegalArgumentException
(
"Unsupported object type: "
+
object
.
getClass
().
getName
());
}
return
true
;
}
/**
* 是否
对象所有元素都不为 null 且
有元素
* 是否
不满足 对象所有元素都为 null 或 没
有元素
*
* @param object 对象
* @return 是否
对象元素都不为 null 且
有元素
* @return 是否
不满足 对象所有元素都为 null 或 没
有元素
*/
public
static
boolean
isNotAllEmpty
(
@NonNull
final
Object
object
)
{
return
!
isAllEmpty
s
(
object
);
return
!
isAllEmpty
(
object
);
}
/**
* 是否 每个对象的
(所有元素都为 null 或 没有元素)
* 是否 每个对象的
所有元素都为 null 或 没有元素
* <p>
* 注意:会遍历 Iterator,后续使用需重新创建,但是和 {@link #isAllEquals(boolean, Function, Object...)}、{@link #isAllEqualsSameIndex(boolean, Function, Object...)} 使用时却无须担心,因为其内部会在调用此方法前就将 Iterator 转换为 List
*
...
...
@@ -405,9 +403,12 @@ public class CollectionUtils {
* </ul>
*
* @param objects 多个对象,只传一个数组请调用 {@link #isAllEmpty(Object)}
* @return 是否 每个对象的
(所有元素都为 null 或 没有元素)
* @return 是否 每个对象的
所有元素都为 null 或 没有元素
*/
public
static
boolean
isAllEmptys
(
final
Object
...
objects
)
{
if
(
objects
==
null
)
{
return
true
;
}
if
(
objects
.
length
<
2
)
{
throw
new
IllegalArgumentException
(
"Objects: length must be greater than 1."
);
}
...
...
@@ -421,10 +422,10 @@ public class CollectionUtils {
}
/**
* 是否
每个对象的 (所有元素都不为 null 且 有元素)
* 是否
不满足 每个对象的 所有元素都为 null 或 没有元素
*
* @param objects 多个对象,只传一个数组请调用 {@link #isNotAllEmpty(Object)}
* @return 是否
每个对象的 (所有元素都不为 null 且 有元素)
* @return 是否
不满足 每个对象的 所有元素都为 null 或 没有元素
*/
public
static
boolean
isNotAllEmptys
(
@NonNull
final
Object
...
objects
)
{
return
!
isAllEmptys
(
objects
);
...
...
@@ -449,21 +450,12 @@ public class CollectionUtils {
public
static
boolean
isAnyEmpty
(
final
Object
object
)
{
if
(
sizeIsEmpty
(
object
))
{
return
true
;
}
if
(
object
instanceof
Collection
<?>)
{
Collection
<?>
obj1
=
(
Collection
<?>)
object
;
return
obj1
.
contains
(
null
);
}
else
if
(
object
instanceof
Iterable
<?>)
{
for
(
Object
o
:
(
Iterable
<?>)
object
)
{
if
(
o
==
null
)
{
return
true
;
}
}
}
else
if
(
object
instanceof
Map
<?,
?>)
{
return
((
Map
<?,
?>)
object
).
containsValue
(
null
);
}
else
if
(
object
instanceof
Object
[])
{
Object
[]
obj1
=
(
Object
[])
object
;
return
Arrays
.
stream
(
obj1
).
anyMatch
(
Objects:
:
isNull
);
}
else
if
(
object
instanceof
Iterator
<?>)
{
Iterator
<?>
obj1
=
(
Iterator
<?>)
object
;
while
(
obj1
.
hasNext
())
{
...
...
@@ -471,6 +463,11 @@ public class CollectionUtils {
return
true
;
}
}
}
else
if
(
object
instanceof
Map
<?,
?>)
{
return
((
Map
<?,
?>)
object
).
containsValue
(
null
);
}
else
if
(
object
instanceof
Object
[])
{
Object
[]
obj1
=
(
Object
[])
object
;
return
Arrays
.
stream
(
obj1
).
anyMatch
(
Objects:
:
isNull
);
}
else
if
(
object
instanceof
Enumeration
<?>)
{
Enumeration
<?>
obj1
=
(
Enumeration
<?>)
object
;
while
(
obj1
.
hasMoreElements
())
{
...
...
@@ -478,22 +475,24 @@ public class CollectionUtils {
return
true
;
}
}
}
else
{
throw
new
IllegalArgumentException
(
"Unsupported object type: "
+
object
.
getClass
().
getName
());
}
return
false
;
}
/**
* 是否
对象不为 null 且 有元素 且 每个元素都不
为 null
* 是否
不满足 任意对象为 null 或 没有元素 或 任意元素
为 null
*
* @param object 对象
* @return 是否
对象不为 null 且 有元素 且 每个元素都不
为 null
* @return 是否
不满足 任意对象为 null 或 没有元素 或 任意元素
为 null
*/
public
static
boolean
isNotAnyEmpty
(
final
Object
object
)
{
return
!
isAnyEmpty
(
object
);
}
/**
* 是否 任意对象
(为 null 或 没有元素 或 任意元素为 null)
* 是否 任意对象
为 null 或 没有元素 或 任意元素为 null
* <p>
* 注意:会遍历 Iterator,后续使用需重新创建,但是和 {@link #isAllEquals(boolean, Function, Object...)}、{@link #isAllEqualsSameIndex(boolean, Function, Object...)} 使用时却无须担心,因为其内部会在调用此方法前就将 Iterator 转换为 List
*
...
...
@@ -506,9 +505,12 @@ public class CollectionUtils {
* </ul>
*
* @param objects 多个对象,只传一个数组请调用 {@link #isAnyEmpty(Object)}
* @return 是否 任意对象
(为 null 或 没有元素 或 任意元素为 null)
* @return 是否 任意对象
为 null 或 没有元素 或 任意元素为 null
*/
public
static
boolean
isAnyEmptys
(
final
Object
...
objects
)
{
if
(
objects
==
null
)
{
return
true
;
}
if
(
objects
.
length
<
2
)
{
throw
new
IllegalArgumentException
(
"Objects: length must be greater than 1."
);
}
...
...
@@ -522,10 +524,10 @@ public class CollectionUtils {
}
/**
* 是否
每个对象 (不为 null 且 有元素 且 每个元素都不为 null)
* 是否
不满足 任意对象 为 null 或 没有元素 或 任意元素为 null
*
* @param objects 多个对象,只传一个数组请调用 {@link #isNotAnyEmpty(Object)}
* @return 是否
每个对象 (不为 null 且 有元素 且 每个元素都不为 null)
* @return 是否
不满足 任意对象 为 null 或 没有元素 或 任意元素为 null
*/
public
static
boolean
isNotAnyEmptys
(
final
Object
...
objects
)
{
return
!
isAnyEmptys
(
objects
);
...
...
src/test/java/top/csaf/junit/CollectionUtilsTest.java
浏览文件 @
057fe923
...
...
@@ -88,45 +88,177 @@ public class CollectionUtilsTest {
// TODO 其他方法
}
@DisplayName
(
"是否 每个集合 都为 null 或 没有元素"
)
@Test
void
isEmptys
()
{
assertThrows
(
NullPointerException
.
class
,
()
->
CollectionUtils
.
isEmptys
(
null
));
assertThrows
(
IllegalArgumentException
.
class
,
()
->
CollectionUtils
.
isEmptys
(
new
ArrayList
<>()));
List
<
Object
>
list
=
new
ArrayList
<>();
List
<
Object
>
list1
=
new
ArrayList
<>();
assertTrue
(
CollectionUtils
.
isEmptys
(
list
,
list1
));
list1
.
add
(
1
);
assertFalse
(
CollectionUtils
.
isEmptys
(
list
,
list1
));
}
@DisplayName
(
"是否不满足 每个集合 都为 null 或 没有元素"
)
@Test
void
isNotEmptys
()
{
assertThrows
(
NullPointerException
.
class
,
()
->
CollectionUtils
.
isNotEmptys
(
null
));
List
<
Object
>
list
=
new
ArrayList
<>();
list
.
add
(
1
);
List
<
Object
>
list1
=
new
ArrayList
<>();
list1
.
add
(
1
);
assertTrue
(
CollectionUtils
.
isNotEmptys
(
list
,
list1
));
}
@DisplayName
(
"是否不满足 对象为 null 或 没有元素"
)
@Test
void
sizeIsNotEmpty
()
{
assertThrows
(
NullPointerException
.
class
,
()
->
CollectionUtils
.
sizeIsNotEmpty
(
null
));
List
<
Object
>
list
=
new
ArrayList
<>();
list
.
add
(
1
);
assertTrue
(
CollectionUtils
.
sizeIsNotEmpty
(
list
));
}
@DisplayName
(
"isAllEmpty:是否 每个对象的 (所有元素都为 null || 没有元素)"
)
@DisplayName
(
"是否 每个对象 都为 null 或 没有元素"
)
@Test
void
sizeIsEmptys
()
{
assertThrows
(
NullPointerException
.
class
,
()
->
CollectionUtils
.
sizeIsEmptys
(
null
));
assertThrows
(
IllegalArgumentException
.
class
,
()
->
CollectionUtils
.
sizeIsEmptys
(
new
ArrayList
<>()));
List
<
Object
>
list
=
new
ArrayList
<>();
List
<
Object
>
list1
=
new
ArrayList
<>();
assertTrue
(
CollectionUtils
.
sizeIsEmptys
(
list
,
list1
));
list1
.
add
(
1
);
assertFalse
(
CollectionUtils
.
sizeIsEmptys
(
list
,
list1
));
}
@DisplayName
(
"是否不满足 每个对象 都为 null 或 没有元素"
)
@Test
void
sizeIsNotEmptys
()
{
assertThrows
(
NullPointerException
.
class
,
()
->
CollectionUtils
.
sizeIsNotEmptys
(
null
));
List
<
Object
>
list
=
new
ArrayList
<>();
list
.
add
(
1
);
List
<
Object
>
list1
=
new
ArrayList
<>();
list1
.
add
(
1
);
assertTrue
(
CollectionUtils
.
sizeIsNotEmptys
(
list
,
list1
));
}
@DisplayName
(
"是否 每个对象的 所有元素都为 null 或 没有元素"
)
@Test
void
isAllEmpty
()
{
List
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
null
);
System
.
out
.
println
(
"[0] 为 null 的列表:"
+
CollectionUtils
.
isAllEmpty
(
list
));
assertTrue
(
CollectionUtils
.
isAllEmpty
(
null
));
List
<
Object
>
list
=
new
ArrayList
<>();
list
.
add
(
1
);
assertFalse
(
CollectionUtils
.
isAllEmpty
(
list
));
assertFalse
(
CollectionUtils
.
isAllEmpty
(
list
.
iterator
()));
List
<
Object
>
emptyList
=
new
ArrayList
<>();
assertTrue
(
CollectionUtils
.
isAllEmpty
(
emptyList
.
iterator
()));
emptyList
.
add
(
null
);
assertTrue
(
CollectionUtils
.
isAllEmpty
(
emptyList
));
assertTrue
(
CollectionUtils
.
isAllEmpty
(
emptyList
.
iterator
()));
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
""
,
null
);
System
.
out
.
println
(
"{\"\", null} 的键值对:"
+
CollectionUtils
.
isAllEmpty
(
map
));
System
.
out
.
println
(
"[null] 的数组:"
+
CollectionUtils
.
isAllEmpty
(
new
Object
[]{
null
}));
System
.
out
.
println
(
"[0] 为 null 的迭代器(Iterator):"
+
CollectionUtils
.
isAllEmpty
(
list
.
iterator
()));
Vector
<
String
>
vector
=
new
Vector
<>();
vector
.
add
(
null
);
System
.
out
.
println
(
"[0] 为 null 的枚举:"
+
CollectionUtils
.
isAllEmpty
(
vector
.
elements
()));
map
.
put
(
"1"
,
1
);
assertFalse
(
CollectionUtils
.
isAllEmpty
(
map
));
assertFalse
(
CollectionUtils
.
isAllEmpty
(
new
Object
[]{
1
}));
assertFalse
(
CollectionUtils
.
isAllEmpty
(
new
Vector
<>(
list
).
elements
()));
assertTrue
(
CollectionUtils
.
isAllEmpty
(
new
Vector
<>().
elements
()));
assertTrue
(
CollectionUtils
.
isAllEmpty
(
new
Vector
<>(
emptyList
).
elements
()));
}
@DisplayName
(
"是否不满足 对象所有元素都为 null 或 没有元素"
)
@Test
void
isNotAllEmpty
()
{
assertThrows
(
NullPointerException
.
class
,
()
->
CollectionUtils
.
isNotAllEmpty
(
null
));
List
<
Object
>
list1
=
new
ArrayList
<>();
list1
.
add
(
1
);
assertTrue
(
CollectionUtils
.
isNotAllEmpty
(
list1
));
}
@DisplayName
(
"是否 每个对象的 所有元素都为 null 或 没有元素"
)
@Test
void
isAllEmptys
()
{
assertTrue
(
CollectionUtils
.
isAllEmptys
(
null
));
assertThrows
(
IllegalArgumentException
.
class
,
()
->
CollectionUtils
.
isAllEmptys
(
new
ArrayList
<>()));
List
<
Object
>
list
=
new
ArrayList
<>();
list
.
add
(
1
);
Object
[]
array
=
{
1
};
assertFalse
(
CollectionUtils
.
isAllEmptys
(
list
,
array
));
assertTrue
(
CollectionUtils
.
isAllEmptys
(
new
ArrayList
<>(),
new
Object
[]{}));
}
@DisplayName
(
"是否不满足 每个对象的 所有元素都为 null 或 没有元素"
)
@Test
void
isNotAllEmptys
()
{
assertThrows
(
NullPointerException
.
class
,
()
->
CollectionUtils
.
isNotAllEmptys
(
null
));
List
<
Object
>
list
=
new
ArrayList
<>();
list
.
add
(
1
);
Object
[]
array
=
{
1
};
assertTrue
(
CollectionUtils
.
isNotAllEmptys
(
list
,
array
));
assertFalse
(
CollectionUtils
.
isNotAllEmptys
(
new
ArrayList
<>(),
new
Object
[]{}));
}
@DisplayName
(
"
isAnyEmpty:是否 任意对象 (为 null || 没有元素 || 任意元素为 null)
"
)
@DisplayName
(
"
是否 任意对象 为 null 或 没有元素 或 任意元素为 null
"
)
@Test
void
isAnyEmpty
()
{
List
<
String
>
list
=
new
ArrayList
<>();
assertTrue
(
CollectionUtils
.
isAnyEmpty
(
null
));
List
<
Object
>
list
=
new
ArrayList
<>();
list
.
add
(
1
);
assertFalse
(
CollectionUtils
.
isAnyEmpty
(
list
));
list
.
add
(
null
);
list
.
add
(
""
);
System
.
out
.
println
(
"[0] 为 null 的列表:"
+
CollectionUtils
.
isAnyEmpty
(
list
));
assertTrue
(
CollectionUtils
.
isAnyEmpty
(
list
)
);
assertTrue
(
CollectionUtils
.
isAnyEmpty
(
list
.
iterator
()
));
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
""
,
null
);
System
.
out
.
println
(
"{\"\", null} 的键值对:"
+
CollectionUtils
.
isAnyEmpty
(
map
));
System
.
out
.
println
(
"[null] 的数组:"
+
CollectionUtils
.
isAnyEmpty
(
new
Object
[]{
null
,
1
}));
System
.
out
.
println
(
"[0] 为 null 的迭代器(Iterator):"
+
CollectionUtils
.
isAnyEmpty
(
list
.
iterator
()));
Vector
<
String
>
vector
=
new
Vector
<>();
vector
.
add
(
null
);
vector
.
add
(
""
);
System
.
out
.
println
(
"[0] 为 null 的枚举:"
+
CollectionUtils
.
isAnyEmpty
(
vector
.
elements
()));
map
.
put
(
"1"
,
1
);
map
.
put
(
"2"
,
null
);
assertTrue
(
CollectionUtils
.
isAnyEmpty
(
map
));
assertTrue
(
CollectionUtils
.
isAnyEmpty
(
new
Object
[]{
null
}));
assertTrue
(
CollectionUtils
.
isAnyEmpty
(
new
Vector
<>(
list
).
elements
()));
}
@DisplayName
(
"是否不满足 任意对象 为 null 或 没有元素 或 任意元素为 null"
)
@Test
void
isNotAnyEmpty
()
{
List
<
Object
>
list
=
new
ArrayList
<>();
assertFalse
(
CollectionUtils
.
isNotAnyEmpty
(
list
));
list
.
add
(
1
);
assertTrue
(
CollectionUtils
.
isNotAnyEmpty
(
list
));
}
@DisplayName
(
"是否 任意对象 为 null 或 没有元素 或 任意元素为 null"
)
@Test
void
isAnyEmptys
()
{
assertTrue
(
CollectionUtils
.
isAnyEmptys
(
null
));
List
<
Object
>
list
=
new
ArrayList
<>();
assertThrows
(
IllegalArgumentException
.
class
,
()
->
CollectionUtils
.
isAnyEmptys
(
list
));
list
.
add
(
1
);
assertTrue
(
CollectionUtils
.
isAnyEmptys
(
list
,
new
Object
[]{}));
assertFalse
(
CollectionUtils
.
isAnyEmptys
(
list
,
new
Object
[]{
1
}));
}
@DisplayName
(
"是否不满足 任意对象 为 null 或 没有元素 或 任意元素为 null"
)
@Test
void
isNotAnyEmptys
()
{
assertTrue
(
CollectionUtils
.
isNotAnyEmptys
(
new
Object
[]{
1
},
new
Object
[]{
1
}));
assertFalse
(
CollectionUtils
.
isNotAnyEmptys
(
null
));
}
@DisplayName
(
"是否 每个对象的每个元素都相等"
)
@Test
void
isAllEquals
()
{
/** {@link CollectionUtils#isAllEquals(boolean, Function, Object...)} */
/** {@link CollectionUtils#isAllEquals(boolean, Function, Object...)
} */
assertThrows
(
NullPointerException
.
class
,
()
->
CollectionUtils
.
isAllEquals
(
true
,
null
,
null
));
assertThrows
(
IllegalArgumentException
.
class
,
()
->
CollectionUtils
.
isAllEquals
(
true
,
null
,
new
Object
[]{}));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录