package com.alibaba.druid.sql.dialect.kingbase.ast.clause;

import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLOver;
import com.alibaba.druid.sql.dialect.kingbase.KingbaseSQLObject;
import com.alibaba.druid.sql.dialect.kingbase.visitor.KingbaseASTVisitor;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;

public class KingbaseSQLOver extends SQLOver implements KingbaseSQLObject {
   protected SQLExpr existingName;
   private WindowingExclude excludeBound;

   public WindowingExclude getExcludeBound() {
      return this.excludeBound;
   }

   public void setExcludeBound(WindowingExclude excludeBound) {
      this.excludeBound = excludeBound;
   }

   protected void accept0(SQLASTVisitor visitor) {
      this.accept0((KingbaseASTVisitor)visitor);
   }

   public void accept0(KingbaseASTVisitor visitor) {
      if (visitor.visit(this)) {
         if (this.existingName != null) {
            this.existingName.accept(visitor);
         }

         if (this.partitionBy != null) {
            for(SQLExpr item : this.partitionBy) {
               if (item != null) {
                  item.accept(visitor);
               }
            }
         }

         if (this.orderBy != null) {
            this.orderBy.accept(visitor);
         }
      }

      visitor.endVisit(this);
   }

   public SQLExpr getExistingName() {
      return this.existingName;
   }

   public void setExistingName(SQLExpr existingName) {
      this.existingName = existingName;
   }

   public static enum WindowingExclude {
      CURRENT_ROW("CURRENT ROW"),
      GROUP("GROUP"),
      TIES("TIES"),
      NO_OTHERS("NO OTHERS");

      public final String name;
      public final String name_lower;

      private WindowingExclude(String name) {
         this.name = name;
         this.name_lower = name.toLowerCase();
      }
   }
}
