/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */

package test.fixtures.basicannotations;

import com.facebook.swift.codec.*;
import com.facebook.swift.codec.ThriftField.Requiredness;
import com.facebook.swift.codec.ThriftField.Recursiveness;
import com.google.common.collect.*;
import java.util.*;
import org.apache.thrift.*;
import org.apache.thrift.async.*;
import org.apache.thrift.meta_data.*;
import org.apache.thrift.server.*;
import org.apache.thrift.transport.*;
import org.apache.thrift.protocol.*;
import org.apache.thrift.meta_data.FieldValueMetaData;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.MoreObjects.ToStringHelper;

@SwiftGenerated
@ThriftStruct(value="MyStructAnnotation", builder=MyStructAnnotation.Builder.class)
public final class MyStructAnnotation {
    private BitSet __isset_bit_vector = new BitSet();

    @ThriftConstructor
    public MyStructAnnotation(
        @ThriftField(value=1, name="count", requiredness=Requiredness.NONE) final long count,
        @ThriftField(value=2, name="name", requiredness=Requiredness.NONE) final String name,
        @ThriftField(value=3, name="extra", requiredness=Requiredness.OPTIONAL) final String extra,
        @ThriftField(value=4, name="nest", requiredness=Requiredness.NONE) final test.fixtures.basicannotations.MyStructNestedAnnotation nest
    ) {
        this.count = count;
        this.name = name;
        this.extra = extra;
        this.nest = nest;
    }
    
    @ThriftConstructor
    protected MyStructAnnotation() {
      this.count = 0L;
      this.name = null;
      this.extra = null;
      this.nest = null;
    }
    
    public static class Builder {
        private final BitSet __optional_isset = new BitSet();
    
        private long count = 0L;
        private String name = null;
        private String extra = null;
        private test.fixtures.basicannotations.MyStructNestedAnnotation nest = null;
    
        @ThriftField(value=1, name="count", requiredness=Requiredness.NONE)
        public Builder setCount(long count) {
            this.count = count;
            return this;
        }
    
        public long getCount() { return count; }
    
            @ThriftField(value=2, name="name", requiredness=Requiredness.NONE)
        public Builder setName(String name) {
            this.name = name;
            return this;
        }
    
        public String getName() { return name; }
    
            @ThriftField(value=3, name="extra", requiredness=Requiredness.OPTIONAL)
        public Builder setExtra(String extra) {
            this.extra = extra;
            return this;
        }
    
        public String getExtra() { return extra; }
    
            @ThriftField(value=4, name="nest", requiredness=Requiredness.NONE)
        public Builder setNest(test.fixtures.basicannotations.MyStructNestedAnnotation nest) {
            this.nest = nest;
            return this;
        }
    
        public test.fixtures.basicannotations.MyStructNestedAnnotation getNest() { return nest; }
    
        public Builder() { }
        public Builder(MyStructAnnotation other) {
            this.count = other.count;
            this.name = other.name;
            this.extra = other.extra;
            this.nest = other.nest;
        }
    
        @ThriftConstructor
        public MyStructAnnotation build() {
            MyStructAnnotation result = new MyStructAnnotation (
                this.count,
                this.name,
                this.extra,
                this.nest
            );
            result.__isset_bit_vector.or(__optional_isset);
            return result;
        }
    }
    
    public static final Map<String, Integer> NAMES_TO_IDS = new HashMap();
    public static final Map<Integer, TField> FIELD_METADATA = new HashMap<>();
    private static final TStruct STRUCT_DESC = new TStruct("MyStructAnnotation");
    private final long count;
    public static final int _COUNT = 1;
    private static final TField COUNT_FIELD_DESC = new TField("count", TType.I64, (short)1);
        private final String name;
    public static final int _NAME = 2;
    private static final TField NAME_FIELD_DESC = new TField("name", TType.STRING, (short)2);
        private final String extra;
    public static final int _EXTRA = 3;
    private static final TField EXTRA_FIELD_DESC = new TField("extra", TType.STRING, (short)3);
        private final test.fixtures.basicannotations.MyStructNestedAnnotation nest;
    public static final int _NEST = 4;
    private static final TField NEST_FIELD_DESC = new TField("nest", TType.STRUCT, (short)4);
    static {
      NAMES_TO_IDS.put("count", 1);
      FIELD_METADATA.put(1, COUNT_FIELD_DESC);
      NAMES_TO_IDS.put("name", 2);
      FIELD_METADATA.put(2, NAME_FIELD_DESC);
      NAMES_TO_IDS.put("extra", 3);
      FIELD_METADATA.put(3, EXTRA_FIELD_DESC);
      NAMES_TO_IDS.put("nest", 4);
      FIELD_METADATA.put(4, NEST_FIELD_DESC);
    }
    
    @ThriftField(value=1, name="count", requiredness=Requiredness.NONE)
    public long getCount() { return count; }
        
    /** don't use this method for new code, it's here to make migrating to swift easier */
    @Deprecated
    public boolean fieldIsSetCount() {
        return __isset_bit_vector.get(_COUNT);
    }
    
    
    @ThriftField(value=2, name="name", requiredness=Requiredness.NONE)
    public String getName() { return name; }
        
    /** don't use this method for new code, it's here to make migrating to swift easier */
    @Deprecated
    public boolean fieldIsSetName() {
        return this.name != null;
    }
    
    
    @ThriftField(value=3, name="extra", requiredness=Requiredness.OPTIONAL)
    public String getExtra() { return extra; }
        
    /** don't use this method for new code, it's here to make migrating to swift easier */
    @Deprecated
    public boolean fieldIsSetExtra() {
        return this.extra != null;
    }
    
    
    @ThriftField(value=4, name="nest", requiredness=Requiredness.NONE)
    public test.fixtures.basicannotations.MyStructNestedAnnotation getNest() { return nest; }
        
    /** don't use this method for new code, it's here to make migrating to swift easier */
    @Deprecated
    public boolean fieldIsSetNest() {
        return this.nest != null;
    }
    
    @Override
    public String toString() {
        ToStringHelper helper = toStringHelper(this);
        helper.add("count", count);
        helper.add("name", name);
        helper.add("extra", extra);
        helper.add("nest", nest);
        return helper.toString();
    }
    
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
    
        MyStructAnnotation other = (MyStructAnnotation)o;
    
        return
            Objects.equals(count, other.count) &&
            Objects.equals(name, other.name) &&
            Objects.equals(extra, other.extra) &&
            Objects.equals(nest, other.nest) &&
            true;
    }
    
    @Override
    public int hashCode() {
        return Arrays.deepHashCode(new Object[] {
            count,
            name,
            extra,
            nest
        });
    }
    
    
    public static MyStructAnnotation read0(TProtocol oprot) throws TException {
      TField __field;
      oprot.readStructBegin(MyStructAnnotation.NAMES_TO_IDS, MyStructAnnotation.FIELD_METADATA);
      MyStructAnnotation.Builder builder = new MyStructAnnotation.Builder();
      while (true) {
        __field = oprot.readFieldBegin();
        if (__field.type == TType.STOP) { break; }
        switch (__field.id) {
        case _COUNT:
          if (__field.type == TType.I64) {
            long count = oprot.readI64();
            builder.setCount(count);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _NAME:
          if (__field.type == TType.STRING) {
            String name = oprot.readString();
            builder.setName(name);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _EXTRA:
          if (__field.type == TType.STRING) {
            String extra = oprot.readString();
            builder.setExtra(extra);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _NEST:
          if (__field.type == TType.STRUCT) {
            test.fixtures.basicannotations.MyStructNestedAnnotation nest = test.fixtures.basicannotations.MyStructNestedAnnotation.read0(oprot);
            builder.setNest(nest);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        default:
          TProtocolUtil.skip(oprot, __field.type);
          break;
        }
        oprot.readFieldEnd();
      }
      oprot.readStructEnd();
      return builder.build();
    }
    
    public void write0(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(COUNT_FIELD_DESC);
      oprot.writeI64(this.count);
      oprot.writeFieldEnd();
      if (this.name != null) {
        oprot.writeFieldBegin(NAME_FIELD_DESC);
        oprot.writeString(this.name);
        oprot.writeFieldEnd();
      }
      if (this.extra != null) {
        oprot.writeFieldBegin(EXTRA_FIELD_DESC);
        oprot.writeString(this.extra);
        oprot.writeFieldEnd();
      }
      if (this.nest != null) {
        oprot.writeFieldBegin(NEST_FIELD_DESC);
        this.nest.write0(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
    
}
