【fix sonar】UUIDGenerator文件

This commit is contained in:
梁琦涛
2023-03-10 18:05:55 +08:00
parent 827fa01cb7
commit ea95382ed9
@@ -43,25 +43,25 @@ public class UUIDGenerator {
private static final int JVM = (int) (System.currentTimeMillis() >>> 8); private static final int JVM = (int) (System.currentTimeMillis() >>> 8);
private final static String format(int intval) { private static final String format(int intval) {
String formatted = Integer.toHexString(intval); String formatted = Integer.toHexString(intval);
StringBuilder buf = new StringBuilder("00000000"); StringBuilder buf = new StringBuilder("00000000");
buf.replace(8 - formatted.length(), 8, formatted); buf.replace(8 - formatted.length(), 8, formatted);
return buf.toString(); return buf.toString();
} }
private final static String format(short shortval) { private static final String format(short shortval) {
String formatted = Integer.toHexString(shortval); String formatted = Integer.toHexString(shortval);
StringBuilder buf = new StringBuilder("0000"); StringBuilder buf = new StringBuilder("0000");
buf.replace(4 - formatted.length(), 4, formatted); buf.replace(4 - formatted.length(), 4, formatted);
return buf.toString(); return buf.toString();
} }
private final static int getJVM() { private static final int getJVM() {
return JVM; return JVM;
} }
private final static short getCount() { private static final short getCount() {
synchronized (UUIDGenerator.class) { synchronized (UUIDGenerator.class) {
if (counter < 0) { if (counter < 0) {
counter = 0; counter = 0;
@@ -73,22 +73,22 @@ public class UUIDGenerator {
/** /**
* Unique in a local network * Unique in a local network
*/ */
private final static int getIP() { private static final int getIP() {
return IP; return IP;
} }
/** /**
* Unique down to millisecond * Unique down to millisecond
*/ */
private final static short getHiTime() { private static final short getHiTime() {
return (short) (System.currentTimeMillis() >>> 32); return (short) (System.currentTimeMillis() >>> 32);
} }
private final static int getLoTime() { private static final int getLoTime() {
return (int) System.currentTimeMillis(); return (int) System.currentTimeMillis();
} }
private final static int toInt(byte[] bytes) { private static final 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 & 0xff) + bytes[i]; result = (result << 8) - (Byte.MIN_VALUE & 0xff) + bytes[i];