package com.chenyang.druid.sql.dialect.hive.ast;

import com.chenyang.druid.DbType;
import com.chenyang.druid.sql.ast.SQLStatementImpl;
import com.chenyang.druid.sql.ast.statement.SQLTableSource;
import com.chenyang.druid.sql.ast.statement.SQLWithSubqueryClause;
import com.chenyang.druid.sql.dialect.hive.visitor.HiveASTVisitor;
import com.chenyang.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;

public class HiveMultiInsertStatement extends SQLStatementImpl {
   protected SQLWithSubqueryClause with;
   private SQLTableSource from;
   private List<HiveInsert> items = new ArrayList();

   public HiveMultiInsertStatement() {
      super(DbType.hive);
   }

   public void setFrom(SQLTableSource from) {
      this.from = from;
   }

   public SQLTableSource getFrom() {
      return this.from;
   }

   public List<HiveInsert> getItems() {
      return this.items;
   }

   public void addItem(HiveInsert item) {
      if (item != null) {
         item.setParent(this);
      }

      this.items.add(item);
   }

   protected void accept0(SQLASTVisitor visitor) {
      if (visitor instanceof HiveASTVisitor) {
         this.accept0((HiveASTVisitor)visitor);
      } else {
         this.acceptChild(visitor, this.with);
         this.acceptChild(visitor, this.from);
         this.acceptChild(visitor, this.items);
      }

   }

   public void accept0(HiveASTVisitor visitor) {
      if (visitor.visit(this)) {
         this.acceptChild(visitor, this.with);
         this.acceptChild(visitor, this.from);
         this.acceptChild(visitor, this.items);
      }

      visitor.endVisit(this);
   }

   public SQLWithSubqueryClause getWith() {
      return this.with;
   }

   public void setWith(SQLWithSubqueryClause with) {
      if (with != null) {
         with.setParent(this);
      }

      this.with = with;
   }
}
