package com.chenyang.druid.sql.ast;

import com.chenyang.druid.sql.visitor.SQLASTVisitor;

public class SQLPartitionByHash extends SQLPartitionBy {
   protected boolean key;
   protected boolean unique;

   public boolean isKey() {
      return this.key;
   }

   public void setKey(boolean key) {
      this.key = key;
   }

   public boolean isUnique() {
      return this.unique;
   }

   public void setUnique(boolean unique) {
      this.unique = unique;
   }

   protected void accept0(SQLASTVisitor visitor) {
      if (visitor.visit(this)) {
         this.acceptChild(visitor, this.columns);
         this.acceptChild(visitor, this.partitionsCount);
         this.acceptChild(visitor, this.getPartitions());
         this.acceptChild(visitor, this.subPartitionBy);
      }

      visitor.endVisit(this);
   }

   public SQLPartitionByHash clone() {
      SQLPartitionByHash x = new SQLPartitionByHash();
      this.cloneTo(x);
      x.key = this.key;
      x.unique = this.unique;

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

      return x;
   }

   public void cloneTo(SQLPartitionByHash x) {
      super.cloneTo(x);
   }
}
