refactor(utils): 重构工具类并添加新功能

- 重构了 AutoConfiguration 类,更新了组件扫描路径
- 优化了 Collection 类中的 getOrDefault 方法,增加了对非 List 集合的支持- 添加了 DateTime 类的高精度时间处理功能
- 新增了 DateTimeToStringConverter 类,用于将 DateTime 转换为字符串
- 更新了 ForEach 类中的遍历方法,提高了代码可读性和性能
This commit is contained in:
2025-09-11 09:46:03 +08:00
parent bbafa86872
commit 1a9553b55d
22 changed files with 2099 additions and 1718 deletions
@@ -22,6 +22,7 @@
package com.mingliqiye.utils.collection;
import com.mingliqiye.utils.stream.SuperStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -127,14 +128,28 @@ public class Collection {
*/
@Nullable
public static <T> T getOrDefault(
@NotNull List<T> list,
@NotNull java.util.Collection<T> list,
int index,
@Nullable T defaultValue
) {
if (index < 0 || index >= list.size()) {
return defaultValue;
}
return list.get(index);
return SuperStream.of(list).get(index);
}
/**
* 获取集合中指定索引的元素。
* 如果索引超出范围则返回null。
*
* @param list 集合
* @param index 索引
* @param <T> 元素类型
* @return 指定索引的元素,如果索引超出范围则返回null
*/
@Nullable
public static <T> T get(@NotNull java.util.Collection<T> list, int index) {
return getOrDefault(list, index, null);
}
/**