package com.alibaba.druid.sql.dialect.sqlserver.ast;

import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
import com.alibaba.druid.sql.ast.statement.SQLSelectItem;
import com.alibaba.druid.sql.dialect.sqlserver.visitor.SQLServerASTVisitor;
import java.util.ArrayList;
import java.util.List;

public class SQLServerOutput extends SQLServerObjectImpl {
   protected SQLExprTableSource into;
   protected final List<SQLExpr> columns = new ArrayList();
   protected final List<SQLSelectItem> selectList = new ArrayList();

   public void accept0(SQLServerASTVisitor visitor) {
      if (visitor.visit(this)) {
         this.acceptChild(visitor, this.selectList);
         this.acceptChild(visitor, this.into);
         this.acceptChild(visitor, this.columns);
      }

      visitor.endVisit(this);
   }

   public SQLExprTableSource getInto() {
      return this.into;
   }

   public void setInto(SQLExprTableSource into) {
      this.into = into;
   }

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

   public List<SQLSelectItem> getSelectList() {
      return this.selectList;
   }

   public SQLServerOutput clone() {
      SQLServerOutput x = new SQLServerOutput();
      if (this.into != null) {
         x.setInto(this.into.clone());
      }

      for(SQLExpr c : this.columns) {
         SQLExpr c2 = c.clone();
         c2.setParent(x);
         x.columns.add(c2);
      }

      for(SQLSelectItem item : this.selectList) {
         SQLSelectItem item2 = item.clone();
         item2.setParent(x);
         x.selectList.add(item2);
      }

      return x;
   }
}
