package com.chenyang.druid.sql.dialect.oracle.ast.stmt;

import com.chenyang.druid.sql.ast.SQLName;
import com.chenyang.druid.sql.ast.statement.SQLUnique;
import com.chenyang.druid.sql.dialect.oracle.ast.OracleSQLObject;
import com.chenyang.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
import com.chenyang.druid.sql.visitor.SQLASTVisitor;

public class OracleUnique extends SQLUnique implements OracleConstraint, OracleSQLObject {
   private OracleUsingIndexClause using;
   private SQLName exceptionsInto;
   private Initially initially;
   private Boolean deferrable;

   protected void accept0(SQLASTVisitor visitor) {
      if (visitor instanceof OracleASTVisitor) {
         this.accept0((OracleASTVisitor)visitor);
      } else {
         super.accept(visitor);
      }
   }

   public void accept0(OracleASTVisitor visitor) {
      if (visitor.visit(this)) {
         this.acceptChild(visitor, this.getName());
         this.acceptChild(visitor, this.getColumns());
         this.acceptChild(visitor, this.using);
         this.acceptChild(visitor, this.exceptionsInto);
      }

      visitor.endVisit(this);
   }

   public Boolean getDeferrable() {
      return this.deferrable;
   }

   public void setDeferrable(Boolean deferrable) {
      this.deferrable = deferrable;
   }

   public SQLName getExceptionsInto() {
      return this.exceptionsInto;
   }

   public void setExceptionsInto(SQLName exceptionsInto) {
      this.exceptionsInto = exceptionsInto;
   }

   public OracleUsingIndexClause getUsing() {
      return this.using;
   }

   public void setUsing(OracleUsingIndexClause using) {
      if (using != null) {
         using.setParent(this);
      }

      this.using = using;
   }

   public Initially getInitially() {
      return this.initially;
   }

   public void setInitially(Initially initially) {
      this.initially = initially;
   }

   public void cloneTo(OracleUnique x) {
      super.cloneTo(x);
      if (this.using != null) {
         x.setUsing(this.using.clone());
      }

      if (this.exceptionsInto != null) {
         x.setExceptionsInto(this.exceptionsInto.clone());
      }

      x.initially = this.initially;
      x.deferrable = this.deferrable;
   }

   public OracleUnique clone() {
      OracleUnique x = new OracleUnique();
      this.cloneTo(x);
      return x;
   }
}
