Skip to content

Commit

Permalink
NetUti类中ipv6ToBitInteger方法名称建议修改成ipv6ToBigInteger
Browse files Browse the repository at this point in the history
  • Loading branch information
looly committed Jul 29, 2022
1 parent 2e4c81b commit a5e1f2f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -3,7 +3,7 @@

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

# 5.8.5.M1 (2022-07-22)
# 5.8.5.M1 (2022-07-29)

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

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

// -------------------------------------------------------------------------- private
Expand Down
19 changes: 16 additions & 3 deletions hutool-core/src/main/java/cn/hutool/core/net/NetUtil.java
Expand Up @@ -86,13 +86,26 @@ public static long ipv4ToLong(String strIP) {
/**
* 将IPv6地址字符串转为大整数
*
* @param IPv6Str 字符串
* @param ipv6Str 字符串
* @return 大整数, 如发生异常返回 null
* @since 5.5.7
* @deprecated 拼写错误,请使用{@link #ipv6ToBigInteger(String)}
*/
public static BigInteger ipv6ToBigInteger(String IPv6Str) {
@Deprecated
public static BigInteger ipv6ToBitInteger(String ipv6Str) {
return ipv6ToBigInteger(ipv6Str);
}

/**
* 将IPv6地址字符串转为大整数
*
* @param ipv6Str 字符串
* @return 大整数, 如发生异常返回 null
* @since 5.5.7
*/
public static BigInteger ipv6ToBigInteger(String ipv6Str) {
try {
InetAddress address = InetAddress.getByName(IPv6Str);
InetAddress address = InetAddress.getByName(ipv6Str);
if (address instanceof Inet6Address) {
return new BigInteger(1, address.getAddress());
}
Expand Down

0 comments on commit a5e1f2f

Please sign in to comment.