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

public class SQLGrantStatement extends SQLPrivilegeStatement {
   private SQLExpr maxQueriesPerHour;
   private SQLExpr maxUpdatesPerHour;
   private SQLExpr maxConnectionsPerHour;
   private SQLExpr maxUserConnections;
   private boolean adminOption;
   private SQLExpr identifiedBy;
   private String identifiedByPassword;
   private boolean withGrantOption;
   public boolean isGrantRole = false;
   public SQLExpr name;

   public SQLGrantStatement() {
   }

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

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

      visitor.endVisit(this);
   }

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

      if (this.users != null) {
         children.addAll(this.users);
      }

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

      return children;
   }

   public SQLObjectType getResourceType() {
      return this.resourceType;
   }

   public void setResourceType(SQLObjectType resourceType) {
      this.resourceType = resourceType;
   }

   public SQLExpr getMaxQueriesPerHour() {
      return this.maxQueriesPerHour;
   }

   public void setMaxQueriesPerHour(SQLExpr maxQueriesPerHour) {
      this.maxQueriesPerHour = maxQueriesPerHour;
   }

   public SQLExpr getMaxUpdatesPerHour() {
      return this.maxUpdatesPerHour;
   }

   public void setMaxUpdatesPerHour(SQLExpr maxUpdatesPerHour) {
      this.maxUpdatesPerHour = maxUpdatesPerHour;
   }

   public SQLExpr getMaxConnectionsPerHour() {
      return this.maxConnectionsPerHour;
   }

   public void setMaxConnectionsPerHour(SQLExpr maxConnectionsPerHour) {
      this.maxConnectionsPerHour = maxConnectionsPerHour;
   }

   public SQLExpr getMaxUserConnections() {
      return this.maxUserConnections;
   }

   public void setMaxUserConnections(SQLExpr maxUserConnections) {
      this.maxUserConnections = maxUserConnections;
   }

   public boolean isAdminOption() {
      return this.adminOption;
   }

   public void setAdminOption(boolean adminOption) {
      this.adminOption = adminOption;
   }

   public SQLExpr getIdentifiedBy() {
      return this.identifiedBy;
   }

   public void setIdentifiedBy(SQLExpr identifiedBy) {
      this.identifiedBy = identifiedBy;
   }

   public String getIdentifiedByPassword() {
      return this.identifiedByPassword;
   }

   public void setIdentifiedByPassword(String identifiedByPassword) {
      this.identifiedByPassword = identifiedByPassword;
   }

   public boolean getWithGrantOption() {
      return this.withGrantOption;
   }

   public void setWithGrantOption(boolean withGrantOption) {
      this.withGrantOption = withGrantOption;
   }
}
