package com.chenyang.druid.sql.dialect.greenplum.ast.stmt;

import com.chenyang.druid.DbType;
import com.chenyang.druid.sql.ast.SQLExpr;
import com.chenyang.druid.sql.ast.SQLName;
import com.chenyang.druid.sql.ast.statement.SQLAlterIndexStatement;
import com.chenyang.druid.sql.ast.statement.SQLAlterStatement;
import com.chenyang.druid.sql.ast.statement.SQLUpdateSetItem;
import com.chenyang.druid.sql.dialect.greenplum.visitor.GPASTVisitor;
import com.chenyang.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;
import util.sqlparse.visitor.common.Objects;

public class GPAlterIndexStatement extends SQLAlterIndexStatement implements GPSQLStatement, SQLAlterStatement {
   private SQLName newName;
   private List<SQLExpr> itemList = new ArrayList();
   private List<SQLUpdateSetItem> parameterList = new ArrayList();
   private SQLExpr newTableSpace;
   private List<SQLExpr> roleList = new ArrayList();
   private boolean setIfExists;
   private boolean setNowait;
   private boolean setTableSpace;
   private boolean setAllIn;
   private boolean setOwnedBy;
   private SetType type;
   private List<SQLExpr> values;

   public GPAlterIndexStatement() {
      this.type = SetType.None;
      this.values = new ArrayList();
      this.dbType = DbType.greenplum;
   }

   public SQLName getNewName() {
      return this.newName;
   }

   public void setNewName(SQLName newName) {
      this.newName = newName;
      if (newName != null) {
         newName.setParent(this);
      }

   }

   public List<SQLExpr> getValues() {
      return this.values;
   }

   public void setValues(List<SQLExpr> values) {
      this.values = values;
   }

   public void addValue(SQLExpr value) {
      this.values.add(value);
      value.setParent(this);
   }

   public SetType getType() {
      return this.type;
   }

   public void setType(SetType type) {
      this.type = type;
   }

   public void accept0(SQLASTVisitor visitor) {
      this.accept0((GPASTVisitor)visitor);
   }

   public void accept0(GPASTVisitor visitor) {
      if (visitor.visit(this)) {
         this.acceptChild(visitor, this.getName());
         this.acceptChild(visitor, this.newName);
         this.acceptChild(visitor, this.parameterList);
         this.acceptChild(visitor, this.roleList);
         this.acceptChild(visitor, this.newTableSpace);
         this.acceptChild(visitor, this.values);
      }

      visitor.endVisit(this);
   }

   public List<SQLUpdateSetItem> getParameterList() {
      return this.parameterList;
   }

   public void setParameterList(List<SQLUpdateSetItem> parameterList) {
      this.parameterList = parameterList;
   }

   public SQLExpr getNewTableSpace() {
      return this.newTableSpace;
   }

   public void setNewTableSpace(SQLExpr newTableSpace) {
      this.newTableSpace = newTableSpace;
   }

   public List<SQLExpr> getRoleList() {
      return this.roleList;
   }

   public void setRoleList(List<SQLExpr> roleList) {
      this.roleList = roleList;
   }

   public boolean isSetNowait() {
      return this.setNowait;
   }

   public void setSetNowait(boolean setNowait) {
      this.setNowait = setNowait;
   }

   public boolean isSetTableSpace() {
      return this.setTableSpace;
   }

   public void setSetTableSpace(boolean setTableSpace) {
      this.setTableSpace = setTableSpace;
   }

   public boolean isSetAllIn() {
      return this.setAllIn;
   }

   public void setSetAllIn(boolean setAllIn) {
      this.setAllIn = setAllIn;
   }

   public boolean isSetOwnedBy() {
      return this.setOwnedBy;
   }

   public void setSetOwnedBy(boolean setOwnedBy) {
      this.setOwnedBy = setOwnedBy;
   }

   public boolean equals(Object o) {
      if (this == o) {
         return true;
      } else if (o != null && this.getClass() == o.getClass()) {
         GPAlterIndexStatement that = (GPAlterIndexStatement)o;
         return this.setNowait == that.setNowait && this.setTableSpace == that.setTableSpace && this.setAllIn == that.setAllIn && this.setOwnedBy == that.setOwnedBy && Objects.equals(this.newName, that.newName) && Objects.equals(this.parameterList, that.parameterList) && Objects.equals(this.newTableSpace, that.newTableSpace) && Objects.equals(this.roleList, that.roleList) && this.type == that.type && Objects.equals(this.values, that.values);
      } else {
         return false;
      }
   }

   public int hashCode() {
      return Objects.hash(this.newName, this.parameterList, this.newTableSpace, this.roleList, this.setNowait, this.setTableSpace, this.setAllIn, this.setOwnedBy, this.type, this.values);
   }

   public boolean isSetIfExists() {
      return this.setIfExists;
   }

   public void setSetIfExists(boolean setIfExists) {
      this.setIfExists = setIfExists;
   }

   public List<SQLExpr> getItemList() {
      return this.itemList;
   }

   public void setItemList(List<SQLExpr> itemList) {
      this.itemList = itemList;
   }

   public static enum SetType {
      None,
      Reset,
      Set;
   }
}
