Skip to content

Commit d128d58

Browse files
committed
perf: 优化 CollectUtil
1 parent 62264d3 commit d128d58

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

simple-common/src/main/java/top/cadecode/common/util/CollectUtil.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,25 @@ public class CollectUtil {
1212
/**
1313
* 判断数组是否为空
1414
*
15-
* @param objects 数组
15+
* @param array 数组
1616
* @return boolean
1717
*/
18-
public static boolean isEmpty(Object[] objects) {
19-
return objects == null || objects.length == 0;
18+
public static <T> boolean isEmpty(T[] array) {
19+
return array == null || array.length == 0;
2020
}
2121

2222
/**
2323
* 判断数组是否包含指定元素
2424
*
25-
* @param objects 数组
26-
* @param o 元素
25+
* @param array 数组
26+
* @param el 元素
2727
* @return boolean
2828
*/
29-
public static boolean contains(Object[] objects, Object o) {
30-
if (objects == null || objects.length == 0) {
29+
public static <T> boolean contains(T[] array, T el) {
30+
if (isEmpty(array)) {
3131
return false;
3232
}
33-
return Arrays.asList(objects).contains(o);
33+
return Arrays.asList(array).contains(el);
3434
}
3535

36-
3736
}

0 commit comments

Comments
 (0)