Skip to content

Commit

Permalink
Prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
looly committed Jan 20, 2022
2 parents 6e19f62 + 41bae74 commit 4fa050c
Show file tree
Hide file tree
Showing 77 changed files with 871 additions and 236 deletions.
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,33 @@

-------------------------------------------------------------------------------------------------------------

# 5.7.20 (2022-01-14)
# 5.7.20 (2022-01-20)

### 🐣新特性
* 【core 】 增加对null值友好的groupingBy操作的Collector实现,可指定map类型(pr#498@Gitee)
* 【core 】 增加KetamaHash(issue#2084@Github)
* 【crypto 】 增加SignUtil
* 【json 】 JSONGetter增加getBeanList方法
* 【core 】 ObjectUtil 添加三个defaultIfXxxx方法,用于节省CPU及内存损耗。(pr#2094@Github)
* 【core 】 ObjectUtil 添加三个defaultIfXxxx方法,用于节省CPU及内存损耗(pr#2094@Github)
* 【db 】 增加单条数据原生upsert语义支持(pr#501@Gitee)
* 【core 】 在CollectorUtil提交Collectors.toMap的对null友好实现,避免NPE(pr#502@Gitee)
* 【http 】 增加HttpGlobalConfig.setIgnoreEOFError(issue#2092@Github)
* 【core 】 RandomUtil.randomStringWithoutStr排除字符串兼容大写字母(pr#503@Gitee)
* 【core 】 LocalDateTime增加isOverlap方法(pr#512@Gitee)
* 【core 】 Ipv4Util.getBeginIpLong、getEndIpLong改为public(pr#508@Gitee)
*
### 🐞Bug修复
* 【core 】 修复setter重载导致匹配错误(issue#2082@Github)
* 【core 】 修复RegexPool汉字匹配范围小问题(pr#2081@Github)
* 【core 】 修复OS中的拼写错误(pr#500@Gitee)
* 【core 】 修复CustomKeyMap的merge失效问题(issue#2086@Github)
* 【core 】 修复FileUtil.appendLines换行问题(issue#I4QCEZ@Gitee)
* 【core 】 修复java.time.Month解析问题(issue#2090@Github)
* 【core 】 修复PathUtil.moveContent移动覆盖导致的问题(issue#I4QV0L@Gitee)
* 【core 】 修复Opt.ofTry中并发环境下线程安全问题(pr#504@Gitee)
* 【core 】 修复PatternFinder中end边界判断问题(issue#2099@Github)
* 【core 】 修复格式化为中文日期时,0被处理为空串(pr#507@Gitee)
* 【core 】 修复UrlPath转义冒号问题(issue#I4RA42@Gitee)

-------------------------------------------------------------------------------------------------------------
# 5.7.19 (2022-01-07)
Expand Down
2 changes: 1 addition & 1 deletion hutool-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>5.7.20-SNAPSHOT</version>
<version>5.7.20</version>
</parent>

<artifactId>hutool-all</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-aop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>5.7.20-SNAPSHOT</version>
<version>5.7.20</version>
</parent>

<artifactId>hutool-aop</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-bloomFilter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>5.7.20-SNAPSHOT</version>
<version>5.7.20</version>
</parent>

<artifactId>hutool-bloomFilter</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>5.7.20-SNAPSHOT</version>
<version>5.7.20</version>
</parent>

<artifactId>hutool-bom</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-cache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>5.7.20-SNAPSHOT</version>
<version>5.7.20</version>
</parent>

<artifactId>hutool-cache</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-captcha/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>5.7.20-SNAPSHOT</version>
<version>5.7.20</version>
</parent>

<artifactId>hutool-captcha</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>5.7.20-SNAPSHOT</version>
<version>5.7.20</version>
</parent>

<artifactId>hutool-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class BeanCopier<T> implements Copier<T>, Serializable {
private static final long serialVersionUID = 1L;

/** 源对象 */
@SuppressWarnings("NonSerializableFieldInSerializableClass")
private final Object source;
/** 目标对象 */
private final T dest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public static <E, T, U> Map<T, Map<U, E>> group2Map(Collection<E> collection,
if (CollUtil.isEmpty(collection) || key1 == null || key2 == null) {
return Collections.emptyMap();
}
return groupBy(collection, key1, Collectors.toMap(key2, Function.identity(), (l, r) -> l), isParallel);
return groupBy(collection, key1, CollectorUtil.toMap(key2, Function.identity(), (l, r) -> l), isParallel);
}

/**
Expand Down
12 changes: 2 additions & 10 deletions hutool-core/src/main/java/cn/hutool/core/collection/CollUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2343,11 +2343,7 @@ public static Class<?> getElementType(Iterator<?> iterator) {
*/
@SuppressWarnings("unchecked")
public static <K, V> ArrayList<V> valuesOfKeys(Map<K, V> map, K... keys) {
final ArrayList<V> values = new ArrayList<>();
for (K k : keys) {
values.add(map.get(k));
}
return values;
return MapUtil.valuesOfKeys(map, new ArrayIter<>(keys));
}

/**
Expand Down Expand Up @@ -2377,11 +2373,7 @@ public static <K, V> ArrayList<V> valuesOfKeys(Map<K, V> map, Iterable<K> keys)
* @since 3.0.9
*/
public static <K, V> ArrayList<V> valuesOfKeys(Map<K, V> map, Iterator<K> keys) {
final ArrayList<V> values = new ArrayList<>();
while (keys.hasNext()) {
values.add(map.get(keys.next()));
}
return values;
return MapUtil.valuesOfKeys(map, keys);
}

// ------------------------------------------------------------------------------------------------- sort
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public static String format(long amount, boolean isUseTraditional){
*/
public static String formatThousand(int amount, boolean isUseTraditional){
Assert.checkBetween(amount, -999, 999, "Number support only: (-999 ~ 999)!");

final String chinese = thousandToChinese(amount, isUseTraditional);
if(amount < 20 && amount > 10){
// "十一"而非"一十一"
Expand Down Expand Up @@ -284,6 +285,11 @@ private static String longToChinese(long amount, boolean isUseTraditional) {
* @return 转换后的汉字
*/
private static String thousandToChinese(int amountPart, boolean isUseTraditional) {
if (amountPart == 0) {
// issue#I4R92H@Gitee
return String.valueOf(DIGITS[0]);
}

int temp = amountPart;

StringBuilder chineseStr = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,12 @@ public static String formatChineseDate(Calendar calendar, boolean withTime) {
result.append(NumberChineseFormatter.formatThousand(day, false));
result.append('日');

// 只替换年月日,时分秒中零不需要替换
String temp = result.toString().replace('零', '〇');
result.delete(0, result.length());
result.append(temp);


if (withTime) {
// 时
int hour = calendar.get(Calendar.HOUR_OF_DAY);
Expand All @@ -570,7 +576,7 @@ public static String formatChineseDate(Calendar calendar, boolean withTime) {
result.append('秒');
}

return result.toString().replace('零', '〇');
return result.toString();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.time.Period;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.chrono.ChronoLocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.temporal.ChronoField;
Expand Down Expand Up @@ -493,7 +494,7 @@ public static LocalDateTime endOfDay(LocalDateTime time) {
* @since 5.7.18
*/
public static LocalDateTime endOfDay(LocalDateTime time, boolean truncateMillisecond) {
if(truncateMillisecond){
if (truncateMillisecond) {
return time.with(LocalTime.of(23, 59, 59));
}
return time.with(LocalTime.MAX);
Expand Down Expand Up @@ -544,4 +545,21 @@ public static boolean isWeekend(LocalDate localDate) {
public static Week dayOfWeek(LocalDate localDate) {
return Week.of(localDate.getDayOfWeek());
}

/**
* 检查两个时间段是否有时间重叠<br>
* 重叠指两个时间段是否有交集
*
* @param realStartTime 第一个时间段的开始时间
* @param realEndTime 第一个时间段的结束时间
* @param startTime 第二个时间段的开始时间
* @param endTime 第二个时间段的结束时间
* @return true 表示时间有重合
* @since 5.7.20
*/
public static boolean isOverlap(ChronoLocalDateTime<?> realStartTime, ChronoLocalDateTime<?> realEndTime,
ChronoLocalDateTime<?> startTime, ChronoLocalDateTime<?> endTime) {
return startTime.isAfter(realEndTime) || endTime.isBefore(realStartTime);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Month;
import java.time.OffsetDateTime;
import java.time.OffsetTime;
import java.time.ZoneId;
Expand Down Expand Up @@ -40,7 +41,8 @@ public static int get(TemporalAccessor temporalAccessor, TemporalField field) {
}

/**
* 格式化日期时间为指定格式
* 格式化日期时间为指定格式<br>
* 如果为{@link Month},调用{@link Month#toString()}
*
* @param time {@link TemporalAccessor}
* @param formatter 日期格式化器,预定义的格式见:{@link DateTimeFormatter}
Expand All @@ -52,6 +54,10 @@ public static String format(TemporalAccessor time, DateTimeFormatter formatter)
return null;
}

if(time instanceof Month){
return time.toString();
}

if(null == formatter){
formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
}
Expand All @@ -74,7 +80,8 @@ public static String format(TemporalAccessor time, DateTimeFormatter formatter)
}

/**
* 格式化日期时间为指定格式
* 格式化日期时间为指定格式<br>
* 如果为{@link Month},调用{@link Month#toString()}
*
* @param time {@link TemporalAccessor}
* @param format 日期格式
Expand All @@ -86,6 +93,10 @@ public static String format(TemporalAccessor time, String format) {
return null;
}

if(time instanceof Month){
return time.toString();
}

// 检查自定义格式
if(GlobalCustomFormat.isCustomFormat(format)){
return GlobalCustomFormat.format(time, format);
Expand All @@ -98,13 +109,17 @@ public static String format(TemporalAccessor time, String format) {
}

/**
* {@link TemporalAccessor}转换为 时间戳(从1970-01-01T00:00:00Z开始的毫秒数)
* {@link TemporalAccessor}转换为 时间戳(从1970-01-01T00:00:00Z开始的毫秒数)<br>
* 如果为{@link Month},调用{@link Month#getValue()}
*
* @param temporalAccessor Date对象
* @return {@link Instant}对象
* @since 5.4.1
*/
public static long toEpochMilli(TemporalAccessor temporalAccessor) {
if(temporalAccessor instanceof Month){
return ((Month) temporalAccessor).getValue();
}
return toInstant(temporalAccessor).toEpochMilli();
}

Expand Down
7 changes: 6 additions & 1 deletion hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2876,7 +2876,12 @@ public static <T> File appendLines(Collection<T> list, String path, Charset char
}

/**
* 将列表写入文件,追加模式
* 将列表写入文件,追加模式,策略为:
* <ul>
* <li>当文件为空,从开头追加,尾部不加空行</li>
* <li>当有内容,换行追加,尾部不加空行</li>
* <li>当有内容,并末尾有空行,依旧换行追加</li>
* </ul>
*
* @param <T> 集合元素类型
* @param list 列表
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.nio.file.AccessDeniedException;
import java.nio.file.CopyOption;
import java.nio.file.DirectoryStream;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.FileVisitOption;
import java.nio.file.FileVisitResult;
import java.nio.file.FileVisitor;
Expand Down Expand Up @@ -516,6 +517,11 @@ public static Path moveContent(Path src, Path target, boolean isOverride) {
try {
return Files.move(src, target, options);
} catch (IOException e) {
if(e instanceof FileAlreadyExistsException){
// 目标文件已存在,直接抛出异常
// issue#I4QV0L@Gitee
throw new IORuntimeException(e);
}
// 移动失败,可能是跨分区移动导致的,采用递归移动方式
try {
Files.walkFileTree(src, new MoveVisitor(src, target, options));
Expand Down
2 changes: 1 addition & 1 deletion hutool-core/src/main/java/cn/hutool/core/lang/Opt.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static <T> Opt<T> ofTry(Func0<T> supplier) {
try {
return Opt.ofNullable(supplier.call());
} catch (Exception e) {
final Opt<T> empty = Opt.empty();
final Opt<T> empty = new Opt<>(null);
empty.exception = e;
return empty;
}
Expand Down
19 changes: 19 additions & 0 deletions hutool-core/src/main/java/cn/hutool/core/map/MapUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1354,4 +1354,23 @@ public static void clear(Map<?, ?>... maps) {
}
}
}

/**
* 从Map中获取指定键列表对应的值列表<br>
* 如果key在map中不存在或key对应值为null,则返回值列表对应位置的值也为null
*
* @param <K> 键类型
* @param <V> 值类型
* @param map {@link Map}
* @param keys 键列表
* @return 值列表
* @since 5.7.20
*/
public static <K, V> ArrayList<V> valuesOfKeys(Map<K, V> map, Iterator<K> keys) {
final ArrayList<V> values = new ArrayList<>();
while (keys.hasNext()) {
values.add(map.get(keys.next()));
}
return values;
}
}
4 changes: 2 additions & 2 deletions hutool-core/src/main/java/cn/hutool/core/net/Ipv4Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public static String getBeginIpStr(String ip, int maskBit) {
* @param maskBit 给定的掩码位,如30
* @return 起始IP的长整型表示
*/
private static Long getBeginIpLong(String ip, int maskBit) {
public static Long getBeginIpLong(String ip, int maskBit) {
return ipv4ToLong(ip) & ipv4ToLong(getMaskByMaskBit(maskBit));
}

Expand Down Expand Up @@ -348,7 +348,7 @@ public static boolean isInnerIP(String ipAddress) {
* @param maskBit 给定的掩码位,如30
* @return 终止IP的长整型表示
*/
private static Long getEndIpLong(String ip, int maskBit) {
public static Long getEndIpLong(String ip, int maskBit) {
return getBeginIpLong(ip, maskBit)
+ ~ipv4ToLong(getMaskByMaskBit(maskBit));
}
Expand Down
Loading

0 comments on commit 4fa050c

Please sign in to comment.