DeviceLockState.java 802 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.xy.utils.enums;
  2. import lombok.AllArgsConstructor;
  3. import lombok.Getter;
  4. import lombok.ToString;
  5. /**
  6. * 锁机状态 1 未锁机 2 已锁机
  7. *
  8. * @author 谭斌
  9. */
  10. @Getter
  11. @ToString
  12. @AllArgsConstructor
  13. public enum DeviceLockState {
  14. UN_LOCK(1, "未锁机"),
  15. LOCK(2, "已锁机");
  16. /**
  17. * 编码值
  18. */
  19. private Integer code;
  20. /**
  21. * 描述
  22. */
  23. private String description;
  24. /**
  25. * 通过code获取enum
  26. *
  27. * @param code
  28. * @return
  29. */
  30. public static DeviceLockState getEnumByCode(Integer code) {
  31. DeviceLockState[] values = values();
  32. for (DeviceLockState value : values) {
  33. if (value.getCode().equals(code)) {
  34. return value;
  35. }
  36. }
  37. return null;
  38. }
  39. }