/**
   * Finishes configuring the CustomChange based on the values passed to {@link #setParam(String,
   * String)} then calls {@link CustomSqlChange#generateStatements(liquibase.database.Database)} or
   * {@link CustomTaskChange#execute(liquibase.database.Database)} depending on the CustomChange
   * implementation.
   *
   * <p>If the CustomChange returns a null SqlStatement array, this method returns an empty array.
   * If a CustomTaskChange is being used, this method will return an empty array.
   */
  @Override
  public SqlStatement[] generateStatements(Database database) {
    SqlStatement[] statements = null;
    try {
      configureCustomChange();
      if (customChange instanceof CustomSqlChange) {
        statements = ((CustomSqlChange) customChange).generateStatements(database);
      } else if (customChange instanceof CustomTaskChange) {
        ((CustomTaskChange) customChange).execute(database);
      } else {
        throw new UnexpectedLiquibaseException(
            customChange.getClass().getName()
                + " does not implement "
                + CustomSqlChange.class.getName()
                + " or "
                + CustomTaskChange.class.getName());
      }
    } catch (CustomChangeException e) {
      throw new UnexpectedLiquibaseException(e);
    }

    if (statements == null) {
      statements = new SqlStatement[0];
    }
    return statements;
  }
  /**
   * Finishes configuring the CustomChange based on the values passed to {@link #setParam(String,
   * String)} then calls {@link
   * CustomSqlRollback#generateRollbackStatements(liquibase.database.Database)} or {@link
   * CustomTaskRollback#rollback(liquibase.database.Database)} depending on the CustomChange
   * implementation.
   *
   * <p>If the CustomChange returns a null SqlStatement array, this method returns an empty array.
   * If a CustomTaskChange is being used, this method will return an empty array. Any {@link
   * RollbackImpossibleException} exceptions thrown by the CustomChange will thrown by this method.
   */
  @Override
  public SqlStatement[] generateRollbackStatements(Database database)
      throws RollbackImpossibleException {
    SqlStatement[] statements = null;
    try {
      configureCustomChange();
      if (customChange instanceof CustomSqlRollback) {
        statements = ((CustomSqlRollback) customChange).generateRollbackStatements(database);
      } else if (customChange instanceof CustomTaskRollback) {
        ((CustomTaskRollback) customChange).rollback(database);
      } else {
        throw new RollbackImpossibleException(
            "Unknown rollback type: " + customChange.getClass().getName());
      }
    } catch (CustomChangeException e) {
      throw new UnexpectedLiquibaseException(e);
    }

    if (statements == null) {
      statements = new SqlStatement[0];
    }
    return statements;
  }