DemandSwitchSign.java 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package com.goafanti.common.enums;
  2. import java.util.HashMap;
  3. import java.util.Map;
  4. import org.apache.commons.lang3.StringUtils;
  5. public enum DemandSwitchSign {
  6. OPEN(0, "不删除成果所有人ID"),
  7. CLOSE(1,"删除成果所有人ID"),
  8. OTHER(2, "其他");
  9. private DemandSwitchSign(Integer code, String desc) {
  10. this.code = code;
  11. this.desc = desc;
  12. }
  13. private static Map<Integer, DemandSwitchSign> status = new HashMap<Integer, DemandSwitchSign>();
  14. static {
  15. for (DemandSwitchSign value : DemandSwitchSign.values()) {
  16. status.put(value.getCode(), value);
  17. }
  18. }
  19. public static DemandSwitchSign getStatus(Integer code) {
  20. if (containsType(code)) {
  21. return status.get(code);
  22. }
  23. return OTHER;
  24. }
  25. public static DemandSwitchSign getStatus(String code) {
  26. if (StringUtils.isNumeric(code)) {
  27. return getStatus(Integer.parseInt(code));
  28. }
  29. return OTHER;
  30. }
  31. public static boolean containsType(Integer code) {
  32. return status.containsKey(code);
  33. }
  34. private Integer code;
  35. private String desc;
  36. public Integer getCode() {
  37. return code;
  38. }
  39. public String getDesc() {
  40. return desc;
  41. }
  42. }