package com.alibaba.druid.sql.ast.statement;

import com.alibaba.druid.sql.ast.SQLName;
import com.alibaba.druid.sql.ast.SQLObjectImpl;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;

public class SQLAlterTableAddColumn extends SQLObjectImpl implements SQLAlterTableItem {
   protected final List<SQLColumnDefinition> columns = new ArrayList();
   private SQLName firstColumn;
   private SQLName afterColumn;
   private boolean first;
   private Boolean restrict;
   private boolean cascade;

   protected void accept0(SQLASTVisitor visitor) {
      if (visitor.visit(this)) {
         this.acceptChild(visitor, this.columns);
      }

      visitor.endVisit(this);
   }

   public List<SQLColumnDefinition> getColumns() {
      return this.columns;
   }

   public void addColumn(SQLColumnDefinition column) {
      if (column != null) {
         column.setParent(this);
      }

      this.columns.add(column);
   }

   public SQLName getFirstColumn() {
      return this.firstColumn;
   }

   public void setFirstColumn(SQLName first) {
      this.firstColumn = first;
   }

   public boolean isFirst() {
      return this.first;
   }

   public void setFirst(boolean first) {
      this.first = first;
   }

   public SQLName getAfterColumn() {
      return this.afterColumn;
   }

   public void setAfterColumn(SQLName after) {
      this.afterColumn = after;
   }

   public Boolean getRestrict() {
      return this.restrict;
   }

   public boolean isRestrict() {
      if (this.restrict == null) {
         return !this.cascade;
      } else {
         return this.restrict;
      }
   }

   public void setRestrict(boolean restrict) {
      this.restrict = restrict;
   }

   public boolean isCascade() {
      return this.cascade;
   }

   public void setCascade(boolean cascade) {
      this.cascade = cascade;
   }
}
