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

@@ -299,8 +299,7 @@ public class BackgroundRemoval {
}
}
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) {
@@ -310,7 +309,7 @@ public class BackgroundRemoval {
}
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();
@@ -327,7 +326,7 @@ public class BackgroundRemoval {
return ImgUtil.toHex(Integer.parseInt(strings[0]), Integer.parseInt(strings[1]),
Integer.parseInt(strings[2]));
}
return "";
return StrUtil.EMPTY;
}
// -------------------------------------------------------------------------- private

View File

@@ -86,13 +86,26 @@ public class NetUtil {
/**
* 将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
* @since 5.5.7
*/
public static BigInteger ipv6ToBigInteger(String IPv6Str) {
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());
}