package com.alibaba.druid.sql.dialect.gauss.ast.stmt.alterTable;

import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.statement.SQLAlterTableItem;
import com.alibaba.druid.sql.dialect.gauss.ast.GaussSQLObject;
import com.alibaba.druid.sql.dialect.gauss.ast.GaussSQLObjectImpl;
import com.alibaba.druid.sql.dialect.gauss.visitor.GaussASTVisitor;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;

public class GaussAlterTableAddConstraint extends GaussSQLObjectImpl implements SQLAlterTableItem, GaussSQLObject {
   private SQLExpr constraint;
   private GaussAlterTableAddConstraintUsingIndex usingIndex;

   public SQLExpr getConstraint() {
      return this.constraint;
   }

   public void setConstraint(SQLExpr constraint) {
      this.constraint = constraint;
   }

   public GaussAlterTableAddConstraintUsingIndex getUsingIndex() {
      return this.usingIndex;
   }

   public void setUsingIndex(GaussAlterTableAddConstraintUsingIndex usingIndex) {
      this.usingIndex = usingIndex;
   }

   public void accept0(SQLASTVisitor visitor) {
      this.accept0((GaussASTVisitor)visitor);
   }

   public void accept0(GaussASTVisitor visitor) {
      if (visitor.visit(this)) {
         this.acceptChild(visitor, this.constraint);
         this.acceptChild(visitor, this.usingIndex);
      }

      visitor.endVisit(this);
   }

   public GaussAlterTableAddConstraint clone() {
      GaussAlterTableAddConstraint c = new GaussAlterTableAddConstraint();
      if (this.constraint != null) {
         c.setConstraint(this.constraint.clone());
      }

      if (this.usingIndex != null) {
         c.setUsingIndex(this.usingIndex.clone());
      }

      return c;
   }

   public static class GaussAlterTableAddConstraintUsingIndex extends GaussSQLObjectImpl {
      private SQLExpr constraint;
      private SQLExpr indexName;
      private ConstraintType type;
      private ConstraintStrategy strategy;

      public SQLExpr getConstraint() {
         return this.constraint;
      }

      public void setConstraint(SQLExpr constraint) {
         this.constraint = constraint;
         constraint.setParent(this);
      }

      public SQLExpr getIndexName() {
         return this.indexName;
      }

      public void setIndexName(SQLExpr indexName) {
         this.indexName = indexName;
         indexName.setParent(this);
      }

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

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

      public ConstraintStrategy getStrategy() {
         return this.strategy;
      }

      public void setStrategy(ConstraintStrategy strategy) {
         this.strategy = strategy;
      }

      public void accept0(SQLASTVisitor visitor) {
         this.accept0((GaussASTVisitor)visitor);
      }

      public void accept0(GaussASTVisitor visitor) {
         if (visitor.visit(this)) {
            this.acceptChild(visitor, this.constraint);
            this.acceptChild(visitor, this.indexName);
         }

         visitor.endVisit(this);
      }

      public GaussAlterTableAddConstraintUsingIndex clone() {
         GaussAlterTableAddConstraintUsingIndex c = new GaussAlterTableAddConstraintUsingIndex();
         c.setConstraint(this.constraint);
         c.setIndexName(this.indexName);
         c.strategy = this.strategy;
         c.type = this.type;
         return c;
      }

      public static enum ConstraintType {
         unique,
         primaryKey;
      }

      public static enum ConstraintStrategy {
         deferable,
         notDeferable,
         initiallyDefered,
         initiallyImmediate;
      }
   }
}
