content: /**
   * DBSyncer Copyright 2020-2023 All Rights Reserved.
   */
  package org.dbsyncer.connector.postgresql;
  
  import org.dbsyncer.connector.postgresql.cdc.DqlPostgreSQLListener;
  import org.dbsyncer.connector.postgresql.validator.DqlPostgreSQLConfigValidator;
  import org.dbsyncer.sdk.connector.ConfigValidator;
  import org.dbsyncer.sdk.connector.database.AbstractDQLConnector;
  import org.dbsyncer.sdk.constant.DatabaseConstant;
  import org.dbsyncer.sdk.enums.ListenerTypeEnum;
  import org.dbsyncer.sdk.listener.DatabaseQuartzListener;
  import org.dbsyncer.sdk.listener.Listener;
  import org.dbsyncer.sdk.model.PageSql;
  import org.dbsyncer.sdk.plugin.ReaderContext;
  
  /**
   * DQLSqlServer连接器实现
   *
   * @Author AE86
   * @Version 1.0.0
   * @Date 2022-05-22 22:56
   */
  public final class DQLPostgreSQLConnector extends AbstractDQLConnector {
  
      private final DqlPostgreSQLConfigValidator configValidator = new DqlPostgreSQLConfigValidator();
  
      @Override
      public String getConnectorType() {
          return "DqlPostgreSQL";
      }
  
      @Override
      public ConfigValidator getConfigValidator() {
          return configValidator;
      }
  
      @Override
      public Listener getListener(String listenerType) {
          if (ListenerTypeEnum.isTiming(listenerType)) {
              return new DatabaseQuartzListener();
          }
  
          if (ListenerTypeEnum.isLog(listenerType)) {
              return new DqlPostgreSQLListener();
          }
          return null;
      }
  
      @Override
      public String getPageSql(PageSql config) {
          return config.getQuerySql() + DatabaseConstant.POSTGRESQL_PAGE_SQL;
      }
  
      @Override
      public Object[] getPageArgs(ReaderContext context) {
          int pageSize = context.getPageSize();
          int pageIndex = context.getPageIndex();
          return new Object[]{pageSize, (pageIndex - 1) * pageSize};
      }
  
      @Override
      public String buildSqlWithQuotation() {
          return "\"";
      }
  }