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.ast.SQLObject;
import com.chenyang.druid.sql.ast.SQLStatementImpl;
import com.chenyang.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;

public class SQLCommentStatement extends SQLStatementImpl {
   private SQLExprTableSource on;
   private Type type;
   private SQLExpr comment;

   public SQLExpr getComment() {
      return this.comment;
   }

   public void setComment(SQLExpr comment) {
      this.comment = comment;
   }

   public Type getType() {
      return this.type;
   }

   public void setType(Type type) {
      this.type = type;
   }

   public SQLExprTableSource getOn() {
      return this.on;
   }

   public void setOn(SQLExprTableSource on) {
      if (on != null) {
         on.setParent(this);
      }

      this.on = on;
   }

   public void setOn(SQLName on) {
      this.setOn(new SQLExprTableSource(on));
   }

   protected void accept0(SQLASTVisitor visitor) {
      if (visitor.visit(this)) {
         this.acceptChild(visitor, this.on);
         this.acceptChild(visitor, this.comment);
      }

      visitor.endVisit(this);
   }

   public List<SQLObject> getChildren() {
      List<SQLObject> children = new ArrayList();
      if (this.on != null) {
         children.add(this.on);
      }

      if (this.comment != null) {
         children.add(this.comment);
      }

      return children;
   }

   public static enum Type {
      TABLE,
      COLUMN,
      VIEW;
   }
}
