PatentReimbursementStatus.java 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 PatentReimbursementStatus {
  6. NO(0, "未报销"),
  7. YES(1, "已报销"),
  8. OTHER(2, "其他");
  9. private PatentReimbursementStatus(Integer code, String desc) {
  10. this.code = code;
  11. this.desc = desc;
  12. }
  13. private static Map<Integer, PatentReimbursementStatus> status = new HashMap<Integer, PatentReimbursementStatus>();
  14. static {
  15. for (PatentReimbursementStatus value : PatentReimbursementStatus.values()) {
  16. status.put(value.getCode(), value);
  17. }
  18. }
  19. public static PatentReimbursementStatus getStatus(Integer code) {
  20. if (containsType(code)) {
  21. return status.get(code);
  22. }
  23. return OTHER;
  24. }
  25. public static PatentReimbursementStatus 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. }