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

import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLHint;
import com.alibaba.druid.sql.ast.statement.SQLInsertInto;
import com.alibaba.druid.sql.ast.statement.SQLSelect;
import com.alibaba.druid.sql.dialect.kingbase.KingbaseSQLObject;
import com.alibaba.druid.sql.dialect.kingbase.KingbaseSQLObjectImpl;
import com.alibaba.druid.sql.dialect.kingbase.visitor.KingbaseASTVisitor;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;

public class KingbaseMultiInsertStatement extends KingbaseStatementImpl {
   private SQLSelect subQuery;
   private Option option;
   private List<Entry> entries = new ArrayList();
   private List<SQLHint> hints = new ArrayList(1);

   public List<SQLHint> getHints() {
      return this.hints;
   }

   public void setHints(List<SQLHint> hints) {
      this.hints = hints;
   }

   public List<Entry> getEntries() {
      return this.entries;
   }

   public void addEntry(Entry entry) {
      if (entry != null) {
         entry.setParent(this);
      }

      this.entries.add(entry);
   }

   public Option getOption() {
      return this.option;
   }

   public void setOption(Option option) {
      this.option = option;
   }

   public SQLSelect getSubQuery() {
      return this.subQuery;
   }

   public void setSubQuery(SQLSelect subQuery) {
      this.subQuery = subQuery;
   }

   public void accept0(KingbaseASTVisitor visitor) {
      if (visitor.visit(this)) {
         this.acceptChild(visitor, this.entries);
         this.acceptChild(visitor, this.subQuery);
      }

      visitor.endVisit(this);
   }

   public static enum Option {
      ALL,
      FIRST;
   }

   public static class ConditionalInsertClause extends KingbaseSQLObjectImpl implements Entry {
      private List<ConditionalInsertClauseItem> items = new ArrayList();
      private InsertIntoClause elseItem;

      public InsertIntoClause getElseItem() {
         return this.elseItem;
      }

      public void setElseItem(InsertIntoClause elseItem) {
         this.elseItem = elseItem;
      }

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

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

         this.items.add(item);
      }

      public void accept0(KingbaseASTVisitor visitor) {
         if (visitor.visit(this)) {
            this.acceptChild(visitor, this.items);
            this.acceptChild(visitor, this.elseItem);
         }

         visitor.endVisit(this);
      }
   }

   public static class ConditionalInsertClauseItem extends KingbaseSQLObjectImpl {
      private SQLExpr when;
      private InsertIntoClause then;

      public SQLExpr getWhen() {
         return this.when;
      }

      public void setWhen(SQLExpr when) {
         this.when = when;
      }

      public InsertIntoClause getThen() {
         return this.then;
      }

      public void setThen(InsertIntoClause then) {
         this.then = then;
      }

      public void accept0(KingbaseASTVisitor visitor) {
         if (visitor.visit(this)) {
            this.acceptChild(visitor, this.when);
            this.acceptChild(visitor, this.then);
         }

         visitor.endVisit(this);
      }
   }

   public static class InsertIntoClause extends SQLInsertInto implements KingbaseSQLObject, Entry {
      public InsertIntoClause() {
         this.dbType = DbType.kingbase;
      }

      public SQLInsertInto clone() {
         InsertIntoClause x = new InsertIntoClause();
         super.cloneTo(x);
         return x;
      }

      protected void accept0(SQLASTVisitor visitor) {
         this.accept0((KingbaseASTVisitor)visitor);
      }

      public void accept0(KingbaseASTVisitor visitor) {
         if (visitor.visit(this)) {
            this.acceptChild(visitor, this.tableSource);
            this.acceptChild(visitor, this.columns);
            this.acceptChild(visitor, this.valuesList);
            this.acceptChild(visitor, this.query);
         }

         visitor.endVisit(this);
      }
   }

   public interface Entry extends KingbaseSQLObject {
   }
}
