/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package com.facebook.thrift.annotation.hack_deprecated;

import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;
import java.util.BitSet;
import java.util.Arrays;
import com.facebook.thrift.*;
import com.facebook.thrift.annotations.*;
import com.facebook.thrift.async.*;
import com.facebook.thrift.meta_data.*;
import com.facebook.thrift.server.*;
import com.facebook.thrift.transport.*;
import com.facebook.thrift.protocol.*;

/**
 * This annotation is for adding Hack attributes.
 * * Where to use: field or struct type
 * * Value: add attributes like `JSEnum` to structs or fields
 * * Example:
 * 
 * ```
 * // In thrift
 * enum MyEnum {
 *   ALLOWED = 1,
 *   THIS_IS_ALLOWED  =  2,
 *   THIS_IS_ALLOWED_2 = 3,
 * }(
 *   hack.attributes=
 *     "\JSEnum(shape('name' => 'MyEnum')),
 *     \GraphQLEnum('MyEnum', 'Description for my enum',)"
 * )
 * struct MyThriftStruct {
 *   1: string foo (hack.attributes = "FieldAttribute");
 *   2: string bar;
 *   3: string baz;
 * } (hack.attributes = "ClassAttribute")
 * ```
 * ```
 * //thrift compiler will generate this for you
 * <<\JSEnum(shape('name' => 'MyEnum')),
 * \GraphQLEnum('MyEnum', 'Description for my enum',)>>
 * enum MyEnum: int {
 *  ALLOWED = 1;
 *  THIS_IS_ALLOWED = 2;
 *  THIS_IS_ALLOWED_2 = 3;
 * }
 * <<ClassAttribute>>
 * class MyThriftStruct implements \IThriftStruct {
 *  ....
 *  <<FieldAttribute>>
 *  public string $foo;
 *  ....
 * }
 * ```
 */
@SuppressWarnings({ "unused", "serial" })
public class Attributes implements TBase, java.io.Serializable, Cloneable {
  private static final TStruct STRUCT_DESC = new TStruct("Attributes");
  private static final TField ATTRIBUTES_FIELD_DESC = new TField("attributes", TType.LIST, (short)1);

  public final List<String> attributes;
  public static final int ATTRIBUTES = 1;

  public Attributes(
      List<String> attributes) {
    this.attributes = attributes;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public Attributes(Attributes other) {
    if (other.isSetAttributes()) {
      this.attributes = TBaseHelper.deepCopy(other.attributes);
    } else {
      this.attributes = null;
    }
  }

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

  public List<String> getAttributes() {
    return this.attributes;
  }

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

  @Override
  public boolean equals(Object _that) {
    if (_that == null)
      return false;
    if (this == _that)
      return true;
    if (!(_that instanceof Attributes))
      return false;
    Attributes that = (Attributes)_that;

    if (!TBaseHelper.equalsNobinary(this.isSetAttributes(), that.isSetAttributes(), this.attributes, that.attributes)) { return false; }

    return true;
  }

  @Override
  public int hashCode() {
    return Arrays.deepHashCode(new Object[] {attributes});
  }

  // This is required to satisfy the TBase interface, but can't be implemented on immutable struture.
  public void read(TProtocol iprot) throws TException {
    throw new TException("unimplemented in android immutable structure");
  }

  public static Attributes deserialize(TProtocol iprot) throws TException {
    List<String> tmp_attributes = null;
    TField __field;
    iprot.readStructBegin();
    while (true)
    {
      __field = iprot.readFieldBegin();
      if (__field.type == TType.STOP) {
        break;
      }
      switch (__field.id)
      {
        case ATTRIBUTES:
          if (__field.type == TType.LIST) {
            {
              TList _list4 = iprot.readListBegin();
              tmp_attributes = new ArrayList<String>(Math.max(0, _list4.size));
              for (int _i5 = 0; 
                   (_list4.size < 0) ? iprot.peekList() : (_i5 < _list4.size); 
                   ++_i5)
              {
                String _elem6;
                _elem6 = iprot.readString();
                tmp_attributes.add(_elem6);
              }
              iprot.readListEnd();
            }
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        default:
          TProtocolUtil.skip(iprot, __field.type);
          break;
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    Attributes _that;
    _that = new Attributes(
      tmp_attributes
    );
    _that.validate();
    return _that;
  }

  public void write(TProtocol oprot) throws TException {
    validate();

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.attributes != null) {
      oprot.writeFieldBegin(ATTRIBUTES_FIELD_DESC);
      {
        oprot.writeListBegin(new TList(TType.STRING, this.attributes.size()));
        for (String _iter7 : this.attributes)        {
          oprot.writeString(_iter7);
        }
        oprot.writeListEnd();
      }
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

  @Override
  public String toString() {
    return toString(1, true);
  }

  @Override
  public String toString(int indent, boolean prettyPrint) {
    return TBaseHelper.toStringHelper(this, indent, prettyPrint);
  }

  public void validate() throws TException {
    // check for required fields
  }

}

