package com.alibaba.druid.sql.dialect.spark.ast.expr;

import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLObject;
import com.alibaba.druid.sql.dialect.spark.ast.SparkSqlExprImpl;
import com.alibaba.druid.sql.dialect.spark.visitor.SparkVisitor;
import java.util.ArrayList;
import java.util.List;
import util.sqlparse.visitor.common.Objects;

public class HiveRowFormat extends SparkSqlExprImpl {
   private RowFormatSede sede;
   private RowFormatDelimitor delimitor;

   public RowFormatSede getSede() {
      return this.sede;
   }

   public void setSede(RowFormatSede sede) {
      this.sede = sede;
   }

   public RowFormatDelimitor getDelimitor() {
      return this.delimitor;
   }

   public void setDelimitor(RowFormatDelimitor delimitor) {
      this.delimitor = delimitor;
   }

   public List<SQLObject> getChildren() {
      List<SQLObject> result = new ArrayList();
      if (this.sede != null) {
         result.add(this.sede);
      }

      if (this.delimitor != null) {
         result.add(this.delimitor);
      }

      return result;
   }

   public void accept0(SparkVisitor v) {
      if (v.visit(this)) {
         this.acceptChild(v, this.sede);
         this.acceptChild(v, this.delimitor);
      }

      v.endVisit(this);
   }

   public boolean equals(Object o) {
      if (this == o) {
         return true;
      } else if (o != null && this.getClass() == o.getClass()) {
         HiveRowFormat that = (HiveRowFormat)o;
         return Objects.equals(this.sede, that.sede) && Objects.equals(this.delimitor, that.delimitor);
      } else {
         return false;
      }
   }

   public int hashCode() {
      return Objects.hash(this.sede, this.delimitor);
   }

   public HiveRowFormat clone() {
      HiveRowFormat e = new HiveRowFormat();
      if (this.sede != null) {
         e.sede = this.sede.clone();
      }

      if (this.delimitor != null) {
         e.delimitor = this.delimitor.clone();
      }

      return e;
   }

   public static class RowFormatSede extends SparkSqlExprImpl {
      private SQLExpr sedeClass;
      private List<SparkDefProperty> props = new ArrayList();

      public SQLExpr getSedeClass() {
         return this.sedeClass;
      }

      public void setSedeClass(SQLExpr sedeClass) {
         this.sedeClass = sedeClass;
      }

      public List<SparkDefProperty> getProps() {
         return this.props;
      }

      public void setProps(List<SparkDefProperty> props) {
         this.props = props;
      }

      public List<SQLObject> getChildren() {
         List<SQLObject> objects = new ArrayList();
         objects.add(this.sedeClass);
         objects.addAll(this.props);
         return objects;
      }

      public void accept0(SparkVisitor v) {
         if (v.visit(this)) {
            this.acceptChild(v, this.sedeClass);
            this.acceptChild(v, this.props);
         }

         v.endVisit(this);
      }

      public RowFormatSede clone() {
         RowFormatSede e = new RowFormatSede();
         e.sedeClass = this.sedeClass.clone();

         for(SparkDefProperty prop : this.props) {
            e.props.add(prop.clone());
         }

         return e;
      }

      public boolean equals(Object o) {
         if (this == o) {
            return true;
         } else if (o != null && this.getClass() == o.getClass()) {
            RowFormatSede that = (RowFormatSede)o;
            return Objects.equals(this.sedeClass, that.sedeClass) && Objects.equals(this.props, that.props);
         } else {
            return false;
         }
      }

      public int hashCode() {
         return Objects.hash(this.sedeClass, this.props);
      }
   }

   public static class RowFormatDelimitor extends SparkSqlExprImpl {
      private SQLExpr fieldTerminatedChar;
      private SQLExpr escapeChar;
      private SQLExpr collectionItemsTerminatedChar;
      private SQLExpr mapKeyTerminatedChar;
      private SQLExpr rowTerminatedChar;
      private SQLExpr nullChar;

      public List<SQLObject> getChildren() {
         List<SQLObject> children = new ArrayList();
         if (this.fieldTerminatedChar != null) {
            children.add(this.fieldTerminatedChar);
         }

         if (this.escapeChar != null) {
            children.add(this.escapeChar);
         }

         if (this.collectionItemsTerminatedChar != null) {
            children.add(this.collectionItemsTerminatedChar);
         }

         if (this.mapKeyTerminatedChar != null) {
            children.add(this.mapKeyTerminatedChar);
         }

         if (this.rowTerminatedChar != null) {
            children.add(this.rowTerminatedChar);
         }

         if (this.nullChar != null) {
            children.add(this.nullChar);
         }

         return children;
      }

      public void accept0(SparkVisitor v) {
         if (v.visit(this)) {
            this.acceptChild(v, this.fieldTerminatedChar);
            this.acceptChild(v, this.escapeChar);
            this.acceptChild(v, this.collectionItemsTerminatedChar);
            this.acceptChild(v, this.mapKeyTerminatedChar);
            this.acceptChild(v, this.rowTerminatedChar);
            this.acceptChild(v, this.nullChar);
         }

      }

      public SQLExpr getFieldTerminatedChar() {
         return this.fieldTerminatedChar;
      }

      public void setFieldTerminatedChar(SQLExpr fieldTerminatedChar) {
         this.fieldTerminatedChar = fieldTerminatedChar;
      }

      public SQLExpr getEscapeChar() {
         return this.escapeChar;
      }

      public void setEscapeChar(SQLExpr escapeChar) {
         this.escapeChar = escapeChar;
      }

      public SQLExpr getCollectionItemsTerminatedChar() {
         return this.collectionItemsTerminatedChar;
      }

      public void setCollectionItemsTerminatedChar(SQLExpr collectionItemsTerminatedChar) {
         this.collectionItemsTerminatedChar = collectionItemsTerminatedChar;
      }

      public SQLExpr getMapKeyTerminatedChar() {
         return this.mapKeyTerminatedChar;
      }

      public void setMapKeyTerminatedChar(SQLExpr mapKeyTerminatedChar) {
         this.mapKeyTerminatedChar = mapKeyTerminatedChar;
      }

      public SQLExpr getRowTerminatedChar() {
         return this.rowTerminatedChar;
      }

      public void setRowTerminatedChar(SQLExpr rowTerminatedChar) {
         this.rowTerminatedChar = rowTerminatedChar;
      }

      public SQLExpr getNullChar() {
         return this.nullChar;
      }

      public void setNullChar(SQLExpr nullChar) {
         this.nullChar = nullChar;
      }

      public boolean equals(Object o) {
         if (this == o) {
            return true;
         } else if (o != null && this.getClass() == o.getClass()) {
            RowFormatDelimitor that = (RowFormatDelimitor)o;
            return Objects.equals(this.fieldTerminatedChar, that.fieldTerminatedChar) && Objects.equals(this.escapeChar, that.escapeChar) && Objects.equals(this.collectionItemsTerminatedChar, that.collectionItemsTerminatedChar) && Objects.equals(this.mapKeyTerminatedChar, that.mapKeyTerminatedChar) && Objects.equals(this.rowTerminatedChar, that.rowTerminatedChar) && Objects.equals(this.nullChar, that.nullChar);
         } else {
            return false;
         }
      }

      public int hashCode() {
         return Objects.hash(this.fieldTerminatedChar, this.escapeChar, this.collectionItemsTerminatedChar, this.mapKeyTerminatedChar, this.rowTerminatedChar, this.nullChar);
      }

      public RowFormatDelimitor clone() {
         RowFormatDelimitor e = new RowFormatDelimitor();
         e.fieldTerminatedChar = this.fieldTerminatedChar.clone();
         e.fieldTerminatedChar = this.escapeChar.clone();
         e.fieldTerminatedChar = this.collectionItemsTerminatedChar.clone();
         e.mapKeyTerminatedChar = this.mapKeyTerminatedChar.clone();
         e.fieldTerminatedChar = this.rowTerminatedChar.clone();
         e.fieldTerminatedChar = this.nullChar.clone();
         return e;
      }
   }
}
