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

import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.statement.SQLAlterTableItem;
import com.alibaba.druid.sql.dialect.db2.ast.DB2SQLObject;
import com.alibaba.druid.sql.dialect.db2.ast.DB2SQLObjectImpl;
import com.alibaba.druid.sql.dialect.db2.visitor.DB2ASTVisitor;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;

public class DB2AlterTableAddConstraint extends DB2SQLObjectImpl implements SQLAlterTableItem, DB2SQLObject {
   private SQLExpr constraint;
   private DB2AlterTableAddConstraintUsingIndex usingIndex;

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

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

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

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

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

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

      visitor.endVisit(this);
   }

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

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

      return c;
   }

   public static class DB2AlterTableAddConstraintUsingIndex extends DB2SQLObjectImpl {
      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((DB2ASTVisitor)visitor);
      }

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

         visitor.endVisit(this);
      }

      public DB2AlterTableAddConstraintUsingIndex clone() {
         DB2AlterTableAddConstraintUsingIndex c = new DB2AlterTableAddConstraintUsingIndex();
         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;
      }
   }
}
