eControlDeviceId.java 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package com.beanit.enums;
  2. import java.util.HashMap;
  3. import java.util.Map;
  4. public enum eControlDeviceId {
  5. ControlDeviceId_Controller (0x00, "ControlDeviceId_Controller"),
  6. ControlDeviceId_Antena1 (0x01, "ControlDeviceId_Antenna1"),
  7. ControlDeviceId_Antena2 (0x02, "ControlDeviceId_Antenna2"),
  8. ControlDeviceId_Antena3 (0x03, "ControlDeviceId_Antenna3"),
  9. ControlDeviceId_Antena4 (0x04, "ControlDeviceId_Antenna4");
  10. private final int value;
  11. private final String string;
  12. private static final Map<Integer, eControlDeviceId> map;
  13. static {
  14. map = new HashMap<>();
  15. for (eControlDeviceId e : values()) {
  16. map.put(Integer.valueOf(e.value), e);
  17. }
  18. }
  19. public static eControlDeviceId getByValue(int value) {
  20. return map.get(Integer.valueOf(value));
  21. }
  22. public static eControlDeviceId getByValue(byte value) {
  23. int intValue = (int)(value & 0x0F);
  24. return map.get(Integer.valueOf(intValue));
  25. }
  26. eControlDeviceId(int value, String string) {
  27. this.value = value;
  28. this.string = string;
  29. }
  30. public int getValue() {
  31. return this.value;
  32. }
  33. public String toString() {
  34. return this.string;
  35. }
  36. }