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

import com.chenyang.druid.sql.ast.SQLExpr;
import com.chenyang.druid.sql.ast.SQLName;
import com.chenyang.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;

public class SQLUnnestTableSource extends SQLTableSourceImpl {
   private final List<SQLExpr> items = new ArrayList();
   protected List<SQLName> columns = new ArrayList();
   private boolean ordinality = false;

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

      v.endVisit(this);
   }

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

   public void addColumn(SQLName column) {
      column.setParent(this);
      this.columns.add(column);
   }

   public boolean isOrdinality() {
      return this.ordinality;
   }

   public void setOrdinality(boolean ordinality) {
      this.ordinality = ordinality;
   }

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

   public void addItem(SQLExpr item) {
      item.setParent(this);
      this.items.add(item);
   }

   public SQLUnnestTableSource clone() {
      SQLUnnestTableSource x = new SQLUnnestTableSource();

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

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

      x.alias = this.alias;
      return x;
   }
}
