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

import com.alibaba.druid.sql.ast.SQLDataType;
import com.alibaba.druid.sql.ast.SQLDeclareItem;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLName;
import com.alibaba.druid.sql.ast.SQLStatementImpl;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;

public class SQLDeclareStatement extends SQLStatementImpl {
   protected List<SQLDeclareItem> items = new ArrayList();

   public SQLDeclareStatement() {
   }

   public SQLDeclareStatement(SQLName name, SQLDataType dataType) {
      this.addItem(new SQLDeclareItem(name, dataType));
   }

   public SQLDeclareStatement(SQLName name, SQLDataType dataType, SQLExpr value) {
      this.addItem(new SQLDeclareItem(name, dataType, value));
   }

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

      visitor.endVisit(this);
   }

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

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

      this.items.add(item);
   }
}
