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

import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLReplaceable;
import com.alibaba.druid.sql.ast.SQLStatementImpl;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;

public class SQLDropUserStatement extends SQLStatementImpl implements SQLDropStatement, SQLReplaceable {
   public boolean cascade;
   public boolean restrict;
   private List<SQLExpr> users = new ArrayList(2);
   protected boolean ifExists = false;

   public boolean isCascade() {
      return this.cascade;
   }

   public void setCascade(boolean cascade) {
      this.cascade = cascade;
   }

   public boolean isRestrict() {
      return this.restrict;
   }

   public void setRestrict(boolean restrict) {
      this.restrict = restrict;
   }

   public SQLDropUserStatement() {
   }

   public SQLDropUserStatement(DbType dbType) {
      super(dbType);
   }

   public boolean isIfExists() {
      return this.ifExists;
   }

   public void setIfExists(boolean ifExists) {
      this.ifExists = ifExists;
   }

   public List<SQLExpr> getUsers() {
      return this.users;
   }

   public void addUser(SQLExpr user) {
      if (user != null) {
         user.setParent(this);
      }

      this.users.add(user);
   }

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

      visitor.endVisit(this);
   }

   public List getChildren() {
      return this.users;
   }

   public boolean replace(SQLExpr expr, SQLExpr target) {
      for(int i = 0; i < this.users.size(); ++i) {
         if (this.users.get(i) == expr) {
            target.setParent(this);
            this.users.set(i, target);
            return true;
         }
      }

      return false;
   }
}
