NetUti类中ipv6ToBitInteger方法名称建议修改成ipv6ToBigInteger

This commit is contained in:
Looly 2022-07-29 21:51:12 +08:00
parent 2e4c81bd01
commit a5e1f2f3c6
3 changed files with 21 additions and 8 deletions

View File

@ -3,7 +3,7 @@
------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------
# 5.8.5.M1 (2022-07-22) # 5.8.5.M1 (2022-07-29)
### ❌不兼容特性 ### ❌不兼容特性
* 【core 】 合成注解相关功能重构,增加@Link及其子注解pr#702@Gitee * 【core 】 合成注解相关功能重构,增加@Link及其子注解pr#702@Gitee
@ -29,6 +29,7 @@
* 【json 】 JSONConfig增加允许重复key配置解决不规整json序列化的问题pr#720@Github * 【json 】 JSONConfig增加允许重复key配置解决不规整json序列化的问题pr#720@Github
* 【core 】 完善了codec包下一些方法的入参空校验pr#719@Gitee * 【core 】 完善了codec包下一些方法的入参空校验pr#719@Gitee
* 【extra 】 完善QrCodeUtil对于DATA_MATRIX生成的形状随机不可指定的功能pr#722@Gitee * 【extra 】 完善QrCodeUtil对于DATA_MATRIX生成的形状随机不可指定的功能pr#722@Gitee
* 【core 】 修改NetUtil.ipv6ToBigInteger原方法标记为过期pr#2485@Github
* *
### 🐞Bug修复 ### 🐞Bug修复
* 【core 】 修复CollUtil里面关于可变参数传null造成的crash问题pr#2428@Github * 【core 】 修复CollUtil里面关于可变参数传null造成的crash问题pr#2428@Github

View File

@ -299,8 +299,7 @@ public class BackgroundRemoval {
} }
} }
int initialCapacity = (int) ((float) list.size() / 0.75F + 1.0F); final Map<String, Integer> map = new HashMap<>(list.size(), 1);
Map<String, Integer> map = new HashMap<>(initialCapacity);
for (String string : list) { for (String string : list) {
Integer integer = map.get(string); Integer integer = map.get(string);
if (integer == null) { if (integer == null) {
@ -310,7 +309,7 @@ public class BackgroundRemoval {
} }
map.put(string, integer); map.put(string, integer);
} }
String max = ""; String max = StrUtil.EMPTY;
long num = 0; long num = 0;
for (Map.Entry<String, Integer> entry : map.entrySet()) { for (Map.Entry<String, Integer> entry : map.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
@ -327,7 +326,7 @@ public class BackgroundRemoval {
return ImgUtil.toHex(Integer.parseInt(strings[0]), Integer.parseInt(strings[1]), return ImgUtil.toHex(Integer.parseInt(strings[0]), Integer.parseInt(strings[1]),
Integer.parseInt(strings[2])); Integer.parseInt(strings[2]));
} }
return ""; return StrUtil.EMPTY;
} }
// -------------------------------------------------------------------------- private // -------------------------------------------------------------------------- private

View File

@ -86,13 +86,26 @@ public class NetUtil {
/** /**
* 将IPv6地址字符串转为大整数 * 将IPv6地址字符串转为大整数
* *
* @param IPv6Str 字符串 * @param ipv6Str 字符串
* @return 大整数, 如发生异常返回 null
* @since 5.5.7
* @deprecated 拼写错误请使用{@link #ipv6ToBigInteger(String)}
*/
@Deprecated
public static BigInteger ipv6ToBitInteger(String ipv6Str) {
return ipv6ToBigInteger(ipv6Str);
}
/**
* 将IPv6地址字符串转为大整数
*
* @param ipv6Str 字符串
* @return 大整数, 如发生异常返回 null * @return 大整数, 如发生异常返回 null
* @since 5.5.7 * @since 5.5.7
*/ */
public static BigInteger ipv6ToBigInteger(String IPv6Str) { public static BigInteger ipv6ToBigInteger(String ipv6Str) {
try { try {
InetAddress address = InetAddress.getByName(IPv6Str); InetAddress address = InetAddress.getByName(ipv6Str);
if (address instanceof Inet6Address) { if (address instanceof Inet6Address) {
return new BigInteger(1, address.getAddress()); return new BigInteger(1, address.getAddress());
} }