diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/IdGenerator.java b/src/main/java/xyz/zhouxy/plusone/commons/util/IdGenerator.java index e66c672..3301641 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/IdGenerator.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/IdGenerator.java @@ -40,15 +40,15 @@ public class IdGenerator { } public static String toSimpleString(UUID uuid) { - return (digits(uuid.getMostSignificantBits() >> 32, 8) + - digits(uuid.getMostSignificantBits() >> 16, 4) + - digits(uuid.getMostSignificantBits(), 4) + - digits(uuid.getLeastSignificantBits() >> 48, 4) + - digits(uuid.getLeastSignificantBits(), 12)); + return (uuidDigits(uuid.getMostSignificantBits() >> 32, 8) + + uuidDigits(uuid.getMostSignificantBits() >> 16, 4) + + uuidDigits(uuid.getMostSignificantBits(), 4) + + uuidDigits(uuid.getLeastSignificantBits() >> 48, 4) + + uuidDigits(uuid.getLeastSignificantBits(), 12)); } /** Returns val represented by the specified number of hex digits. */ - private static String digits(long val, int digits) { + private static String uuidDigits(long val, int digits) { long hi = 1L << (digits * 4); return Long.toHexString(hi | (val & (hi - 1))).substring(1); }