package com.chenyang.druid.sql.ast;

import com.chenyang.druid.sql.dialect.oracle.ast.OracleSegmentAttributes;
import com.chenyang.druid.sql.dialect.oracle.ast.OracleSegmentAttributesImpl;
import com.chenyang.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;

public class SQLPartition extends OracleSegmentAttributesImpl implements OracleSegmentAttributes {
   protected SQLName name;
   protected SQLExpr subPartitionsCount;
   protected List<SQLSubPartition> subPartitions = new ArrayList();
   protected SQLPartitionValue values;
   protected SQLExpr dataDirectory;
   protected SQLExpr indexDirectory;
   protected SQLExpr maxRows;
   protected SQLExpr minRows;
   protected SQLExpr engine;
   protected SQLExpr comment;
   protected boolean segmentCreationImmediate;
   protected boolean segmentCreationDeferred;
   private SQLObject lobStorage;

   public SQLName getName() {
      return this.name;
   }

   public void setName(SQLName name) {
      if (name != null) {
         name.setParent(this);
      }

      this.name = name;
   }

   public SQLExpr getSubPartitionsCount() {
      return this.subPartitionsCount;
   }

   public void setSubPartitionsCount(SQLExpr subPartitionsCount) {
      if (subPartitionsCount != null) {
         subPartitionsCount.setParent(this);
      }

      this.subPartitionsCount = subPartitionsCount;
   }

   public SQLPartitionValue getValues() {
      return this.values;
   }

   public void setValues(SQLPartitionValue values) {
      if (values != null) {
         values.setParent(this);
      }

      this.values = values;
   }

   public List<SQLSubPartition> getSubPartitions() {
      return this.subPartitions;
   }

   public void addSubPartition(SQLSubPartition partition) {
      if (partition != null) {
         partition.setParent(this);
      }

      this.subPartitions.add(partition);
   }

   public SQLExpr getIndexDirectory() {
      return this.indexDirectory;
   }

   public void setIndexDirectory(SQLExpr indexDirectory) {
      if (indexDirectory != null) {
         indexDirectory.setParent(this);
      }

      this.indexDirectory = indexDirectory;
   }

   public SQLExpr getDataDirectory() {
      return this.dataDirectory;
   }

   public void setDataDirectory(SQLExpr dataDirectory) {
      if (dataDirectory != null) {
         dataDirectory.setParent(this);
      }

      this.dataDirectory = dataDirectory;
   }

   public SQLExpr getMaxRows() {
      return this.maxRows;
   }

   public void setMaxRows(SQLExpr maxRows) {
      if (maxRows != null) {
         maxRows.setParent(this);
      }

      this.maxRows = maxRows;
   }

   public SQLExpr getMinRows() {
      return this.minRows;
   }

   public void setMinRows(SQLExpr minRows) {
      if (minRows != null) {
         minRows.setParent(this);
      }

      this.minRows = minRows;
   }

   public SQLExpr getEngine() {
      return this.engine;
   }

   public void setEngine(SQLExpr engine) {
      if (engine != null) {
         engine.setParent(this);
      }

      this.engine = engine;
   }

   public SQLExpr getComment() {
      return this.comment;
   }

   public void setComment(SQLExpr comment) {
      if (comment != null) {
         comment.setParent(this);
      }

      this.comment = comment;
   }

   protected void accept0(SQLASTVisitor visitor) {
      if (visitor.visit(this)) {
         this.acceptChild(visitor, this.name);
         this.acceptChild(visitor, this.values);
         this.acceptChild(visitor, this.dataDirectory);
         this.acceptChild(visitor, this.indexDirectory);
         this.acceptChild(visitor, this.tablespace);
         this.acceptChild(visitor, this.maxRows);
         this.acceptChild(visitor, this.minRows);
         this.acceptChild(visitor, this.engine);
         this.acceptChild(visitor, this.comment);
         this.acceptChild(visitor, this.subPartitionsCount);
         this.acceptChild(visitor, this.storage);
         this.acceptChild(visitor, this.subPartitions);
      }

      visitor.endVisit(this);
   }

   public SQLObject getLobStorage() {
      return this.lobStorage;
   }

   public void setLobStorage(SQLObject lobStorage) {
      if (lobStorage != null) {
         lobStorage.setParent(this);
      }

      this.lobStorage = lobStorage;
   }

   public boolean isSegmentCreationImmediate() {
      return this.segmentCreationImmediate;
   }

   public void setSegmentCreationImmediate(boolean segmentCreationImmediate) {
      this.segmentCreationImmediate = segmentCreationImmediate;
   }

   public boolean isSegmentCreationDeferred() {
      return this.segmentCreationDeferred;
   }

   public void setSegmentCreationDeferred(boolean segmentCreationDeferred) {
      this.segmentCreationDeferred = segmentCreationDeferred;
   }

   public SQLPartition clone() {
      SQLPartition x = new SQLPartition();
      if (this.name != null) {
         x.setName(this.name.clone());
      }

      if (this.subPartitionsCount != null) {
         x.setSubPartitionsCount(this.subPartitionsCount.clone());
      }

      for(SQLSubPartition p : this.subPartitions) {
         SQLSubPartition p2 = p.clone();
         p2.setParent(x);
         x.subPartitions.add(p2);
      }

      if (this.values != null) {
         x.setValues(this.values.clone());
      }

      if (this.dataDirectory != null) {
         x.setDataDirectory(this.dataDirectory.clone());
      }

      if (this.indexDirectory != null) {
         x.setDataDirectory(this.indexDirectory.clone());
      }

      if (this.maxRows != null) {
         x.setDataDirectory(this.maxRows.clone());
      }

      if (this.minRows != null) {
         x.setDataDirectory(this.minRows.clone());
      }

      if (this.engine != null) {
         x.setDataDirectory(this.engine.clone());
      }

      if (this.comment != null) {
         x.setDataDirectory(this.comment.clone());
      }

      x.segmentCreationImmediate = this.segmentCreationImmediate;
      x.segmentCreationDeferred = this.segmentCreationDeferred;
      if (this.lobStorage != null) {
         x.setLobStorage(this.lobStorage.clone());
      }

      return x;
   }
}
