IdUtils.java 1006 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package com.ruoyi.common.utils;
  2. import com.ruoyi.common.core.lang.UUID;
  3. /**
  4. * ID生成器工具类
  5. *
  6. * @author ruoyi
  7. */
  8. public class IdUtils
  9. {
  10. /**
  11. * 获取随机UUID
  12. *
  13. * @return 随机UUID
  14. */
  15. public static String randomUUID()
  16. {
  17. return UUID.randomUUID().toString();
  18. }
  19. /**
  20. * 简化的UUID,去掉了横线
  21. *
  22. * @return 简化的UUID,去掉了横线
  23. */
  24. public static String simpleUUID()
  25. {
  26. return UUID.randomUUID().toString(true);
  27. }
  28. /**
  29. * 获取随机UUID,使用性能更好的ThreadLocalRandom生成UUID
  30. *
  31. * @return 随机UUID
  32. */
  33. public static String fastUUID()
  34. {
  35. return UUID.fastUUID().toString();
  36. }
  37. /**
  38. * 简化的UUID,去掉了横线,使用性能更好的ThreadLocalRandom生成UUID
  39. *
  40. * @return 简化的UUID,去掉了横线
  41. */
  42. public static String fastSimpleUUID()
  43. {
  44. return UUID.fastUUID().toString(true);
  45. }
  46. }