PrimaryKeyMappingEnum.java 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * DBSyncer Copyright 2019-2024 All Rights Reserved.
  3. */
  4. package org.dbsyncer.parser.enums;
  5. import org.apache.commons.lang.StringUtils;
  6. import org.dbsyncer.connector.enums.ConnectorEnum;
  7. import org.dbsyncer.parser.strategy.PrimaryKeyMappingStrategy;
  8. import org.dbsyncer.parser.strategy.impl.OraclePrimaryKeyMappingStrategy;
  9. /**
  10. * 主键映射策略枚举
  11. *
  12. * @author AE86
  13. * @version 1.0.0
  14. * @date 2020/10/19 14:19
  15. */
  16. public enum PrimaryKeyMappingEnum {
  17. /**
  18. * Oracle
  19. */
  20. ORACLE(ConnectorEnum.ORACLE.getType(), new OraclePrimaryKeyMappingStrategy());
  21. private String type;
  22. private PrimaryKeyMappingStrategy primaryKeyMappingStrategy;
  23. PrimaryKeyMappingEnum(String type, PrimaryKeyMappingStrategy primaryKeyMappingStrategy) {
  24. this.type = type;
  25. this.primaryKeyMappingStrategy = primaryKeyMappingStrategy;
  26. }
  27. /**
  28. * 主键映射策略
  29. *
  30. * @param type
  31. * @return
  32. */
  33. public static PrimaryKeyMappingStrategy getPrimaryKeyMappingStrategy(String type) {
  34. for (PrimaryKeyMappingEnum e : PrimaryKeyMappingEnum.values()) {
  35. if (StringUtils.equals(type, e.getType())) {
  36. return e.getPrimaryKeyMappingStrategy();
  37. }
  38. }
  39. return new PrimaryKeyMappingStrategy() {};
  40. }
  41. public String getType() {
  42. return type;
  43. }
  44. public PrimaryKeyMappingStrategy getPrimaryKeyMappingStrategy() {
  45. return primaryKeyMappingStrategy;
  46. }
  47. }