ModelEnum.java 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package org.dbsyncer.parser.enums;
  2. import org.dbsyncer.common.util.StringUtil;
  3. import org.dbsyncer.parser.ParserException;
  4. /**
  5. * 驱动同步方式枚举
  6. *
  7. * @author AE86
  8. * @version 1.0.0
  9. * @date 2020/04/21 16:19
  10. */
  11. public enum ModelEnum {
  12. /**
  13. * 全量
  14. */
  15. FULL("full", "全量"),
  16. /**
  17. * 增量
  18. */
  19. INCREMENT("increment", "增量");
  20. private String code;
  21. private String name;
  22. ModelEnum(String code, String name) {
  23. this.code = code;
  24. this.name = name;
  25. }
  26. public static ModelEnum getModelEnum(String code) throws ParserException {
  27. for (ModelEnum e : ModelEnum.values()) {
  28. if (StringUtil.equals(code, e.getCode())) {
  29. return e;
  30. }
  31. }
  32. throw new ParserException(String.format("Model code \"%s\" does not exist.", code));
  33. }
  34. public static boolean isFull(String model) {
  35. return StringUtil.equals(FULL.getCode(), model);
  36. }
  37. public String getCode() {
  38. return code;
  39. }
  40. public void setCode(String code) {
  41. this.code = code;
  42. }
  43. public String getName() {
  44. return name;
  45. }
  46. public void setName(String name) {
  47. this.name = name;
  48. }
  49. }