add method

This commit is contained in:
Looly 2021-11-02 23:35:10 +08:00
parent c663713680
commit 8614aecced
3 changed files with 17 additions and 3 deletions

View File

@ -20,6 +20,8 @@
* 【core 】 Opt增加peeks方法pr#445@Gitee * 【core 】 Opt增加peeks方法pr#445@Gitee
* 【extra 】 MailAccount中user默认值改为邮箱全称issue#I4FYVY@Gitee * 【extra 】 MailAccount中user默认值改为邮箱全称issue#I4FYVY@Gitee
* 【core 】 增加CoordinateUtilpr#446@Gitee * 【core 】 增加CoordinateUtilpr#446@Gitee
* 【core 】 DateUtil增加rangeToList重载pr#1925@Github
* 【core 】 CollUtil增加safeContains方法pr#1926@Github
### 🐞Bug修复 ### 🐞Bug修复
* 【core 】 修复UrlBuilder.addPath歧义问题issue#1912@Github * 【core 】 修复UrlBuilder.addPath歧义问题issue#1912@Github

View File

@ -425,14 +425,16 @@ public class CollUtil {
/** /**
* 判断指定集合是否包含指定值如果集合为空null或者空返回{@code false}否则找到元素返回{@code true} * 判断指定集合是否包含指定值如果集合为空null或者空返回{@code false}否则找到元素返回{@code true}
*
* @param collection 集合 * @param collection 集合
* @param value 需要查找的值 * @param value 需要查找的值
* @return 果集合为空null或者空返回{@code false}否则找到元素返回{@code true} * @return 果集合为空null或者空返回{@code false}否则找到元素返回{@code true}
* @since 5.7.16
*/ */
public static boolean safeContains(Collection<?> collection, Object value) { public static boolean safeContains(Collection<?> collection, Object value) {
try { try {
return contains(collection ,value); return contains(collection, value);
} catch (ClassCastException | NullPointerException e) { } catch (ClassCastException | NullPointerException e) {
return false; return false;
} }

View File

@ -1877,6 +1877,16 @@ public class DateUtil extends CalendarUtil {
return CollUtil.newArrayList((Iterable<DateTime>) range(start, end, unit)); return CollUtil.newArrayList((Iterable<DateTime>) range(start, end, unit));
} }
/**
* 创建日期范围生成器
*
* @param start 起始日期时间
* @param end 结束日期时间
* @param unit 步进单位
* @param step 步进
* @return {@link DateRange}
* @since 5.7.16
*/
public static List<DateTime> rangeToList(Date start, Date end, final DateField unit, int step) { public static List<DateTime> rangeToList(Date start, Date end, final DateField unit, int step) {
return CollUtil.newArrayList((Iterable<DateTime>) new DateRange(start, end, unit, step)); return CollUtil.newArrayList((Iterable<DateTime>) new DateRange(start, end, unit, step));
} }