【fix sonar】UUIDGenerator文件

This commit is contained in:
梁琦涛
2023-03-06 11:36:11 +08:00
parent 910662a5a0
commit 20ddd56f93
@@ -4,16 +4,20 @@ package com.jero.common.util;
import java.net.InetAddress; import java.net.InetAddress;
/** /**
* *
* @Author 张代浩 * @Author 张代浩
* *
*/ */
public class UUIDGenerator { public class UUIDGenerator {
private UUIDGenerator(){
}
/** /**
* 产生一个32位的UUID * 产生一个32位的UUID
* *
* @return * @return
*/ */
@@ -21,7 +25,7 @@ public class UUIDGenerator {
return new StringBuilder(32).append(format(getIP())).append( return new StringBuilder(32).append(format(getIP())).append(
format(getJVM())).append(format(getHiTime())).append( format(getJVM())).append(format(getHiTime())).append(
format(getLoTime())).append(format(getCount())).toString(); format(getLoTime())).append(format(getCount())).toString();
} }
private static final int IP; private static final int IP;
@@ -87,9 +91,8 @@ public class UUIDGenerator {
private final static int toInt(byte[] bytes) { private final static int toInt(byte[] bytes) {
int result = 0; int result = 0;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
result = (result << 8) - Byte.MIN_VALUE + (int) bytes[i]; result = (result << 8) - (Byte.MIN_VALUE & 0xff) + bytes[i];
} }
return result; return result;
} }
} }