IntentionSate.java 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package com.goafanti.order.enums;
  2. import java.util.HashMap;
  3. import java.util.Map;
  4. public enum IntentionSate {
  5. /** 待卖方确认 **/
  6. WAIT_SELLER_CONFIRM(0,"WAIT_SELLER_CONFIRM"),
  7. /** 卖方已确认 **/
  8. SELLER_CONFIRM(1,"SELLER_CONFIRM"),
  9. /** 卖方已拒绝 **/
  10. SELLER_REFUSE(2,"SELLER_REFUSE"),
  11. /** 买方已取消 **/
  12. BUYER_CANCELLED(3,"BUYER_CANCELLED"),
  13. /** 已过期 **/
  14. EXPIRED(4,"EXPIRED"),
  15. /** 无效 **/
  16. INVALID(10, "INVALID");
  17. private IntentionSate(Integer code, String desc) {
  18. this.code = code;
  19. this.desc = desc;
  20. }
  21. private static Map<Integer, IntentionSate> status = new HashMap<Integer, IntentionSate>();
  22. static {
  23. for (IntentionSate value : IntentionSate.values()) {
  24. status.put(value.getCode(), value);
  25. }
  26. }
  27. public static IntentionSate getStatus(Integer code) {
  28. if (containsType(code)) {
  29. return status.get(code);
  30. }
  31. return INVALID;
  32. }
  33. public static boolean containsType(Integer code) {
  34. return status.containsKey(code);
  35. }
  36. private Integer code;
  37. private String desc;
  38. public Integer getCode() {
  39. return code;
  40. }
  41. public void setCode(Integer code) {
  42. this.code = code;
  43. }
  44. public String getDesc() {
  45. return desc;
  46. }
  47. public void setDesc(String desc) {
  48. this.desc = desc;
  49. }
  50. }