package com.chenyang.druid.sql.ast.statement;

import com.chenyang.druid.sql.ast.SQLName;
import com.chenyang.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;

public class SQLColumnReference extends SQLConstraintImpl implements SQLColumnConstraint {
   private SQLName table;
   private List<SQLName> columns = new ArrayList();
   private SQLForeignKeyImpl.Match referenceMatch;
   protected SQLForeignKeyImpl.Option onUpdate;
   protected SQLForeignKeyImpl.Option onDelete;

   protected void accept0(SQLASTVisitor visitor) {
      if (visitor.visit(this)) {
         this.acceptChild(visitor, this.getName());
      }

      visitor.endVisit(this);
   }

   public SQLName getTable() {
      return this.table;
   }

   public void setTable(SQLName table) {
      this.table = table;
   }

   public List<SQLName> getColumns() {
      return this.columns;
   }

   public void setColumns(List<SQLName> columns) {
      this.columns = columns;
   }

   public SQLColumnReference clone() {
      SQLColumnReference x = new SQLColumnReference();
      super.cloneTo((SQLConstraintImpl)x);
      if (this.table != null) {
         x.setTable(this.table.clone());
      }

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

      x.referenceMatch = this.referenceMatch;
      x.onUpdate = this.onUpdate;
      x.onDelete = this.onDelete;
      return x;
   }

   public SQLForeignKeyImpl.Match getReferenceMatch() {
      return this.referenceMatch;
   }

   public void setReferenceMatch(SQLForeignKeyImpl.Match referenceMatch) {
      this.referenceMatch = referenceMatch;
   }

   public SQLForeignKeyImpl.Option getOnUpdate() {
      return this.onUpdate;
   }

   public void setOnUpdate(SQLForeignKeyImpl.Option onUpdate) {
      this.onUpdate = onUpdate;
   }

   public SQLForeignKeyImpl.Option getOnDelete() {
      return this.onDelete;
   }

   public void setOnDelete(SQLForeignKeyImpl.Option onDelete) {
      this.onDelete = onDelete;
   }
}
