GenderIntEnum.java 942 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.xjrsoft.common.enums;
  2. public enum GenderIntEnum {
  3. /**
  4. * 男
  5. */
  6. MALE("SB10001", 1),
  7. /**
  8. * 女
  9. */
  10. FEMALE("SB10002", 2);
  11. final String code;
  12. final Integer value;
  13. public String getCode() {
  14. return this.code;
  15. }
  16. public Integer getValue() {
  17. return this.value;
  18. }
  19. public static Integer getValue(String code) {
  20. for (GenderIntEnum item : values()) {
  21. if (item.getCode().equals(code)) {
  22. return item.getValue();
  23. }
  24. }
  25. return null;
  26. }
  27. GenderIntEnum(final String code, final Integer message) {
  28. this.code = code;
  29. this.value = message;
  30. }
  31. public static String getCode(Integer value) {
  32. for (GenderIntEnum item : values()) {
  33. if (item.getValue() == value) {
  34. return item.getCode();
  35. }
  36. }
  37. return null;
  38. }
  39. }