package com.alibaba.druid.sql.dialect.greenplum.ast.stmt.alterTable;

import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.statement.SQLAlterTableItem;
import com.alibaba.druid.sql.dialect.greenplum.ast.GPSQLObjectImpl;
import com.alibaba.druid.sql.dialect.greenplum.visitor.GPASTVisitor;
import java.util.ArrayList;
import java.util.List;

public class GPAlterTableSetNewTableSpace extends GPSQLObjectImpl implements SQLAlterTableItem {
   private SQLExpr name;
   private List<SQLExpr> owners = new ArrayList();
   private SQLExpr newTablespace = null;
   private boolean nowait = false;

   public void accept0(GPASTVisitor visitor) {
      if (visitor.visit(this)) {
         this.acceptChild(visitor, this.name);
         this.acceptChild(visitor, this.owners);
         this.acceptChild(visitor, this.newTablespace);
      }

      visitor.endVisit(this);
   }

   public void addOwner(SQLExpr owner) {
      owner.setParent(this);
      this.owners.add(owner);
   }

   public SQLExpr getNewTablespace() {
      return this.newTablespace;
   }

   public void setNewTablespace(SQLExpr newTablespace) {
      this.newTablespace = newTablespace;
      newTablespace.setParent(this);
   }

   public List<SQLExpr> getOwners() {
      return this.owners;
   }

   public void setOwners(List<SQLExpr> owners) {
      this.owners = owners;
   }

   public boolean isNowait() {
      return this.nowait;
   }

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

   public SQLExpr getName() {
      return this.name;
   }

   public void setName(SQLExpr name) {
      this.name = name;
      name.setParent(this);
   }

   public GPAlterTableSetNewTableSpace clone() {
      GPAlterTableSetNewTableSpace c = new GPAlterTableSetNewTableSpace();
      c.setName(this.name.clone());

      for(SQLExpr owner : this.owners) {
         c.addOwner(owner.clone());
      }

      c.setNewTablespace(this.newTablespace.clone());
      c.nowait = this.nowait;
      return c;
   }
}
