package com.chenyang.druid.sql.dialect.postgresql.ast.stmt.alterTable;

import com.chenyang.druid.sql.ast.SQLExpr;
import com.chenyang.druid.sql.ast.statement.SQLAlterTableItem;
import com.chenyang.druid.sql.dialect.postgresql.ast.PGSQLObjectImpl;
import com.chenyang.druid.sql.dialect.postgresql.visitor.PGASTVisitor;
import com.chenyang.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;

public class PGAlterTableAlterColumnOptions extends PGSQLObjectImpl implements SQLAlterTableItem {
   private boolean set = false;
   private List<PGAlterTableAlterColumnOptionValue> options = new ArrayList();

   public boolean isSet() {
      return this.set;
   }

   public void setSet(boolean set) {
      this.set = set;
   }

   public List<PGAlterTableAlterColumnOptionValue> getOptions() {
      return this.options;
   }

   public void setOptions(List<PGAlterTableAlterColumnOptionValue> options) {
      this.options = options;
   }

   public void addOption(PGAlterTableAlterColumnOptionValue option) {
      this.options.add(option);
      option.setParent(this);
   }

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

   public void accept0(PGASTVisitor visitor) {
      if (visitor.visit(this)) {
         this.acceptChild(visitor, this.options);
      }

      visitor.endVisit(this);
   }

   public PGAlterTableAlterColumnOptions clone() {
      PGAlterTableAlterColumnOptions c = new PGAlterTableAlterColumnOptions();
      c.set = this.set;

      for(PGAlterTableAlterColumnOptionValue option : this.options) {
         c.addOption(option.clone());
      }

      return c;
   }

   public static class PGAlterTableAlterColumnOptionValue extends PGSQLObjectImpl {
      private SQLExpr attribute;
      private SQLExpr value;

      public SQLExpr getAttribute() {
         return this.attribute;
      }

      public void setAttribute(SQLExpr attribute) {
         this.attribute = attribute;
         attribute.setParent(this);
      }

      public SQLExpr getValue() {
         return this.value;
      }

      public void setValue(SQLExpr value) {
         this.value = value;
         value.setParent(this);
      }

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

      public void accept0(PGASTVisitor visitor) {
         if (visitor.visit(this)) {
            this.acceptChild(visitor, this.attribute);
            this.acceptChild(visitor, this.value);
         }

         visitor.endVisit(this);
      }

      public PGAlterTableAlterColumnOptionValue clone() {
         PGAlterTableAlterColumnOptionValue option = new PGAlterTableAlterColumnOptionValue();
         option.setAttribute(this.attribute.clone());
         if (this.value != null) {
            option.setValue(this.value.clone());
         }

         return option;
      }
   }
}
