GeospatialStatistics.java

/**
 * Autogenerated by Thrift Compiler (0.16.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package org.apache.parquet.format;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
/**
 * Statistics specific to Geometry and Geography logical types
 */
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)", date = "2026-05-14")
public class GeospatialStatistics implements org.apache.thrift.TBase<GeospatialStatistics, GeospatialStatistics._Fields>, java.io.Serializable, Cloneable, Comparable<GeospatialStatistics> {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("GeospatialStatistics");

  private static final org.apache.thrift.protocol.TField BBOX_FIELD_DESC = new org.apache.thrift.protocol.TField("bbox", org.apache.thrift.protocol.TType.STRUCT, (short)1);
  private static final org.apache.thrift.protocol.TField GEOSPATIAL_TYPES_FIELD_DESC = new org.apache.thrift.protocol.TField("geospatial_types", org.apache.thrift.protocol.TType.LIST, (short)2);

  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new GeospatialStatisticsStandardSchemeFactory();
  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new GeospatialStatisticsTupleSchemeFactory();

  /**
   * A bounding box of geospatial instances
   */
  public @org.apache.thrift.annotation.Nullable BoundingBox bbox; // optional
  /**
   * Geospatial type codes of all instances, or an empty list if not known
   */
  public @org.apache.thrift.annotation.Nullable java.util.List<java.lang.Integer> geospatial_types; // optional

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    /**
     * A bounding box of geospatial instances
     */
    BBOX((short)1, "bbox"),
    /**
     * Geospatial type codes of all instances, or an empty list if not known
     */
    GEOSPATIAL_TYPES((short)2, "geospatial_types");

    private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();

    static {
      for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
        byName.put(field.getFieldName(), field);
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    @org.apache.thrift.annotation.Nullable
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // BBOX
          return BBOX;
        case 2: // GEOSPATIAL_TYPES
          return GEOSPATIAL_TYPES;
        default:
          return null;
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, throwing an exception
     * if it is not found.
     */
    public static _Fields findByThriftIdOrThrow(int fieldId) {
      _Fields fields = findByThriftId(fieldId);
      if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }

    /**
     * Find the _Fields constant that matches name, or null if its not found.
     */
    @org.apache.thrift.annotation.Nullable
    public static _Fields findByName(java.lang.String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final java.lang.String _fieldName;

    _Fields(short thriftId, java.lang.String fieldName) {
      _thriftId = thriftId;
      _fieldName = fieldName;
    }

    public short getThriftFieldId() {
      return _thriftId;
    }

    public java.lang.String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  private static final _Fields optionals[] = {_Fields.BBOX,_Fields.GEOSPATIAL_TYPES};
  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
  static {
    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.BBOX, new org.apache.thrift.meta_data.FieldMetaData("bbox", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, BoundingBox.class)));
    tmpMap.put(_Fields.GEOSPATIAL_TYPES, new org.apache.thrift.meta_data.FieldMetaData("geospatial_types", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(GeospatialStatistics.class, metaDataMap);
  }

  public GeospatialStatistics() {
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public GeospatialStatistics(GeospatialStatistics other) {
    if (other.isSetBbox()) {
      this.bbox = new BoundingBox(other.bbox);
    }
    if (other.isSetGeospatialTypes()) {
      java.util.List<java.lang.Integer> __this__geospatial_types = new java.util.ArrayList<java.lang.Integer>(other.geospatial_types);
      this.geospatial_types = __this__geospatial_types;
    }
  }

  public GeospatialStatistics deepCopy() {
    return new GeospatialStatistics(this);
  }

  @Override
  public void clear() {
    this.bbox = null;
    this.geospatial_types = null;
  }

  /**
   * A bounding box of geospatial instances
   */
  @org.apache.thrift.annotation.Nullable
  public BoundingBox getBbox() {
    return this.bbox;
  }

  /**
   * A bounding box of geospatial instances
   */
  public GeospatialStatistics setBbox(@org.apache.thrift.annotation.Nullable BoundingBox bbox) {
    this.bbox = bbox;
    return this;
  }

  public void unsetBbox() {
    this.bbox = null;
  }

  /** Returns true if field bbox is set (has been assigned a value) and false otherwise */
  public boolean isSetBbox() {
    return this.bbox != null;
  }

  public void setBboxIsSet(boolean value) {
    if (!value) {
      this.bbox = null;
    }
  }

  public int getGeospatialTypesSize() {
    return (this.geospatial_types == null) ? 0 : this.geospatial_types.size();
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.Iterator<java.lang.Integer> getGeospatialTypesIterator() {
    return (this.geospatial_types == null) ? null : this.geospatial_types.iterator();
  }

  public void addToGeospatialTypes(int elem) {
    if (this.geospatial_types == null) {
      this.geospatial_types = new java.util.ArrayList<java.lang.Integer>();
    }
    this.geospatial_types.add(elem);
  }

  /**
   * Geospatial type codes of all instances, or an empty list if not known
   */
  @org.apache.thrift.annotation.Nullable
  public java.util.List<java.lang.Integer> getGeospatialTypes() {
    return this.geospatial_types;
  }

  /**
   * Geospatial type codes of all instances, or an empty list if not known
   */
  public GeospatialStatistics setGeospatialTypes(@org.apache.thrift.annotation.Nullable java.util.List<java.lang.Integer> geospatial_types) {
    this.geospatial_types = geospatial_types;
    return this;
  }

  public void unsetGeospatialTypes() {
    this.geospatial_types = null;
  }

  /** Returns true if field geospatial_types is set (has been assigned a value) and false otherwise */
  public boolean isSetGeospatialTypes() {
    return this.geospatial_types != null;
  }

  public void setGeospatialTypesIsSet(boolean value) {
    if (!value) {
      this.geospatial_types = null;
    }
  }

  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
    switch (field) {
    case BBOX:
      if (value == null) {
        unsetBbox();
      } else {
        setBbox((BoundingBox)value);
      }
      break;

    case GEOSPATIAL_TYPES:
      if (value == null) {
        unsetGeospatialTypes();
      } else {
        setGeospatialTypes((java.util.List<java.lang.Integer>)value);
      }
      break;

    }
  }

  @org.apache.thrift.annotation.Nullable
  public java.lang.Object getFieldValue(_Fields field) {
    switch (field) {
    case BBOX:
      return getBbox();

    case GEOSPATIAL_TYPES:
      return getGeospatialTypes();

    }
    throw new java.lang.IllegalStateException();
  }

  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
  public boolean isSet(_Fields field) {
    if (field == null) {
      throw new java.lang.IllegalArgumentException();
    }

    switch (field) {
    case BBOX:
      return isSetBbox();
    case GEOSPATIAL_TYPES:
      return isSetGeospatialTypes();
    }
    throw new java.lang.IllegalStateException();
  }

  @Override
  public boolean equals(java.lang.Object that) {
    if (that instanceof GeospatialStatistics)
      return this.equals((GeospatialStatistics)that);
    return false;
  }

  public boolean equals(GeospatialStatistics that) {
    if (that == null)
      return false;
    if (this == that)
      return true;

    boolean this_present_bbox = true && this.isSetBbox();
    boolean that_present_bbox = true && that.isSetBbox();
    if (this_present_bbox || that_present_bbox) {
      if (!(this_present_bbox && that_present_bbox))
        return false;
      if (!this.bbox.equals(that.bbox))
        return false;
    }

    boolean this_present_geospatial_types = true && this.isSetGeospatialTypes();
    boolean that_present_geospatial_types = true && that.isSetGeospatialTypes();
    if (this_present_geospatial_types || that_present_geospatial_types) {
      if (!(this_present_geospatial_types && that_present_geospatial_types))
        return false;
      if (!this.geospatial_types.equals(that.geospatial_types))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    int hashCode = 1;

    hashCode = hashCode * 8191 + ((isSetBbox()) ? 131071 : 524287);
    if (isSetBbox())
      hashCode = hashCode * 8191 + bbox.hashCode();

    hashCode = hashCode * 8191 + ((isSetGeospatialTypes()) ? 131071 : 524287);
    if (isSetGeospatialTypes())
      hashCode = hashCode * 8191 + geospatial_types.hashCode();

    return hashCode;
  }

  @Override
  public int compareTo(GeospatialStatistics other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.compare(isSetBbox(), other.isSetBbox());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetBbox()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.bbox, other.bbox);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetGeospatialTypes(), other.isSetGeospatialTypes());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetGeospatialTypes()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.geospatial_types, other.geospatial_types);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  @org.apache.thrift.annotation.Nullable
  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    scheme(iprot).read(iprot, this);
  }

  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    scheme(oprot).write(oprot, this);
  }

  @Override
  public java.lang.String toString() {
    java.lang.StringBuilder sb = new java.lang.StringBuilder("GeospatialStatistics(");
    boolean first = true;

    if (isSetBbox()) {
      sb.append("bbox:");
      if (this.bbox == null) {
        sb.append("null");
      } else {
        sb.append(this.bbox);
      }
      first = false;
    }
    if (isSetGeospatialTypes()) {
      if (!first) sb.append(", ");
      sb.append("geospatial_types:");
      if (this.geospatial_types == null) {
        sb.append("null");
      } else {
        sb.append(this.geospatial_types);
      }
      first = false;
    }
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    // check for sub-struct validity
    if (bbox != null) {
      bbox.validate();
    }
  }

  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
    try {
      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
    try {
      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private static class GeospatialStatisticsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public GeospatialStatisticsStandardScheme getScheme() {
      return new GeospatialStatisticsStandardScheme();
    }
  }

  private static class GeospatialStatisticsStandardScheme extends org.apache.thrift.scheme.StandardScheme<GeospatialStatistics> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, GeospatialStatistics struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TField schemeField;
      iprot.readStructBegin();
      while (true)
      {
        schemeField = iprot.readFieldBegin();
        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
          break;
        }
        switch (schemeField.id) {
          case 1: // BBOX
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.bbox = new BoundingBox();
              struct.bbox.read(iprot);
              struct.setBboxIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // GEOSPATIAL_TYPES
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list16 = iprot.readListBegin();
                struct.geospatial_types = new java.util.ArrayList<java.lang.Integer>(_list16.size);
                int _elem17;
                for (int _i18 = 0; _i18 < _list16.size; ++_i18)
                {
                  _elem17 = iprot.readI32();
                  struct.geospatial_types.add(_elem17);
                }
                iprot.readListEnd();
              }
              struct.setGeospatialTypesIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          default:
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
        }
        iprot.readFieldEnd();
      }
      iprot.readStructEnd();

      // check for required fields of primitive type, which can't be checked in the validate method
      struct.validate();
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot, GeospatialStatistics struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.bbox != null) {
        if (struct.isSetBbox()) {
          oprot.writeFieldBegin(BBOX_FIELD_DESC);
          struct.bbox.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.geospatial_types != null) {
        if (struct.isSetGeospatialTypes()) {
          oprot.writeFieldBegin(GEOSPATIAL_TYPES_FIELD_DESC);
          {
            oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.geospatial_types.size()));
            for (int _iter19 : struct.geospatial_types)
            {
              oprot.writeI32(_iter19);
            }
            oprot.writeListEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class GeospatialStatisticsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public GeospatialStatisticsTupleScheme getScheme() {
      return new GeospatialStatisticsTupleScheme();
    }
  }

  private static class GeospatialStatisticsTupleScheme extends org.apache.thrift.scheme.TupleScheme<GeospatialStatistics> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, GeospatialStatistics struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet optionals = new java.util.BitSet();
      if (struct.isSetBbox()) {
        optionals.set(0);
      }
      if (struct.isSetGeospatialTypes()) {
        optionals.set(1);
      }
      oprot.writeBitSet(optionals, 2);
      if (struct.isSetBbox()) {
        struct.bbox.write(oprot);
      }
      if (struct.isSetGeospatialTypes()) {
        {
          oprot.writeI32(struct.geospatial_types.size());
          for (int _iter20 : struct.geospatial_types)
          {
            oprot.writeI32(_iter20);
          }
        }
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, GeospatialStatistics struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet incoming = iprot.readBitSet(2);
      if (incoming.get(0)) {
        struct.bbox = new BoundingBox();
        struct.bbox.read(iprot);
        struct.setBboxIsSet(true);
      }
      if (incoming.get(1)) {
        {
          org.apache.thrift.protocol.TList _list21 = iprot.readListBegin(org.apache.thrift.protocol.TType.I32);
          struct.geospatial_types = new java.util.ArrayList<java.lang.Integer>(_list21.size);
          int _elem22;
          for (int _i23 = 0; _i23 < _list21.size; ++_i23)
          {
            _elem22 = iprot.readI32();
            struct.geospatial_types.add(_elem22);
          }
        }
        struct.setGeospatialTypesIsSet(true);
      }
    }
  }

  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
  }
}