/**
 * 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 javax.annotation.Nullable;
import org.apache.thrift.*;
import org.apache.thrift.transport.*;
import org.apache.thrift.protocol.*;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.MoreObjects.ToStringHelper;

@SwiftGenerated
@com.facebook.swift.codec.ThriftStruct(value="MyStruct", builder=MyStruct.Builder.class)
public final class MyStruct implements com.facebook.thrift.payload.ThriftSerializable {
    @ThriftConstructor
    public MyStruct(
        @com.facebook.swift.codec.ThriftField(value=2, name="major", requiredness=Requiredness.NONE) final long major,
        @com.facebook.swift.codec.ThriftField(value=1, name="abstract", requiredness=Requiredness.NONE) final String _abstract,
        @com.facebook.swift.codec.ThriftField(value=3, name="annotation_with_quote", requiredness=Requiredness.NONE) final String annotationWithQuote,
        @com.facebook.swift.codec.ThriftField(value=4, name="class_", requiredness=Requiredness.NONE) final String class_,
        @com.facebook.swift.codec.ThriftField(value=5, name="annotation_with_trailing_comma", requiredness=Requiredness.NONE) final String annotationWithTrailingComma,
        @com.facebook.swift.codec.ThriftField(value=6, name="empty_annotations", requiredness=Requiredness.NONE) final String emptyAnnotations,
        @com.facebook.swift.codec.ThriftField(value=7, name="my_enum", requiredness=Requiredness.NONE) final test.fixtures.basicannotations.MyEnum myEnum,
        @com.facebook.swift.codec.ThriftField(value=8, name="cpp_type_annotation", requiredness=Requiredness.NONE) final List<String> cppTypeAnnotation,
        @com.facebook.swift.codec.ThriftField(value=9, name="my_union", requiredness=Requiredness.NONE) final test.fixtures.basicannotations.MyUnion myUnion
    ) {
        this.major = major;
        this._abstract = _abstract;
        this.annotationWithQuote = annotationWithQuote;
        this.class_ = class_;
        this.annotationWithTrailingComma = annotationWithTrailingComma;
        this.emptyAnnotations = emptyAnnotations;
        this.myEnum = myEnum;
        this.cppTypeAnnotation = cppTypeAnnotation;
        this.myUnion = myUnion;
    }
    
    @ThriftConstructor
    protected MyStruct() {
      this.major = 0L;
      this._abstract = null;
      this.annotationWithQuote = null;
      this.class_ = null;
      this.annotationWithTrailingComma = null;
      this.emptyAnnotations = null;
      this.myEnum = test.fixtures.basicannotations.MyEnum.fromInteger(0);
      this.cppTypeAnnotation = null;
      this.myUnion = null;
    }
    
    public static Builder builder() {
      return new Builder();
    }

    public static Builder builder(MyStruct other) {
      return new Builder(other);
    }

    public static class Builder {
        private long major = 0L;
        private String _abstract = null;
        private String annotationWithQuote = null;
        private String class_ = null;
        private String annotationWithTrailingComma = null;
        private String emptyAnnotations = null;
        private test.fixtures.basicannotations.MyEnum myEnum = test.fixtures.basicannotations.MyEnum.fromInteger(0);
        private List<String> cppTypeAnnotation = null;
        private test.fixtures.basicannotations.MyUnion myUnion = null;
    
        @com.facebook.swift.codec.ThriftField(value=2, name="major", requiredness=Requiredness.NONE)
        public Builder setMajor(long major) {
            this.major = major;
            return this;
        }
    
        public long getMajor() { return major; }
    
            @com.facebook.swift.codec.ThriftField(value=1, name="abstract", requiredness=Requiredness.NONE)
        public Builder setAbstract(String _abstract) {
            this._abstract = _abstract;
            return this;
        }
    
        public String getAbstract() { return _abstract; }
    
            @com.facebook.swift.codec.ThriftField(value=3, name="annotation_with_quote", requiredness=Requiredness.NONE)
        public Builder setAnnotationWithQuote(String annotationWithQuote) {
            this.annotationWithQuote = annotationWithQuote;
            return this;
        }
    
        public String getAnnotationWithQuote() { return annotationWithQuote; }
    
            @com.facebook.swift.codec.ThriftField(value=4, name="class_", requiredness=Requiredness.NONE)
        public Builder setClass_(String class_) {
            this.class_ = class_;
            return this;
        }
    
        public String getClass_() { return class_; }
    
            @com.facebook.swift.codec.ThriftField(value=5, name="annotation_with_trailing_comma", requiredness=Requiredness.NONE)
        public Builder setAnnotationWithTrailingComma(String annotationWithTrailingComma) {
            this.annotationWithTrailingComma = annotationWithTrailingComma;
            return this;
        }
    
        public String getAnnotationWithTrailingComma() { return annotationWithTrailingComma; }
    
            @com.facebook.swift.codec.ThriftField(value=6, name="empty_annotations", requiredness=Requiredness.NONE)
        public Builder setEmptyAnnotations(String emptyAnnotations) {
            this.emptyAnnotations = emptyAnnotations;
            return this;
        }
    
        public String getEmptyAnnotations() { return emptyAnnotations; }
    
            @com.facebook.swift.codec.ThriftField(value=7, name="my_enum", requiredness=Requiredness.NONE)
        public Builder setMyEnum(test.fixtures.basicannotations.MyEnum myEnum) {
            this.myEnum = myEnum;
            return this;
        }
    
        public test.fixtures.basicannotations.MyEnum getMyEnum() { return myEnum; }
    
            @com.facebook.swift.codec.ThriftField(value=8, name="cpp_type_annotation", requiredness=Requiredness.NONE)
        public Builder setCppTypeAnnotation(List<String> cppTypeAnnotation) {
            this.cppTypeAnnotation = cppTypeAnnotation;
            return this;
        }
    
        public List<String> getCppTypeAnnotation() { return cppTypeAnnotation; }
    
            @com.facebook.swift.codec.ThriftField(value=9, name="my_union", requiredness=Requiredness.NONE)
        public Builder setMyUnion(test.fixtures.basicannotations.MyUnion myUnion) {
            this.myUnion = myUnion;
            return this;
        }
    
        public test.fixtures.basicannotations.MyUnion getMyUnion() { return myUnion; }
    
        public Builder() { }
        public Builder(MyStruct other) {
            this.major = other.major;
            this._abstract = other._abstract;
            this.annotationWithQuote = other.annotationWithQuote;
            this.class_ = other.class_;
            this.annotationWithTrailingComma = other.annotationWithTrailingComma;
            this.emptyAnnotations = other.emptyAnnotations;
            this.myEnum = other.myEnum;
            this.cppTypeAnnotation = other.cppTypeAnnotation;
            this.myUnion = other.myUnion;
        }
    
        @ThriftConstructor
        public MyStruct build() {
            MyStruct result = new MyStruct (
                this.major,
                this._abstract,
                this.annotationWithQuote,
                this.class_,
                this.annotationWithTrailingComma,
                this.emptyAnnotations,
                this.myEnum,
                this.cppTypeAnnotation,
                this.myUnion
            );
            return result;
        }
    }
        
    public static final Map<String, Integer> NAMES_TO_IDS = new HashMap<>();
    public static final Map<String, Integer> THRIFT_NAMES_TO_IDS = new HashMap<>();
    public static final Map<Integer, TField> FIELD_METADATA = new HashMap<>();
    private static final TStruct STRUCT_DESC = new TStruct("MyStruct");
    private final long major;
    public static final int _MAJOR = 2;
    private static final TField MAJOR_FIELD_DESC = new TField("major", TType.I64, (short)2);
        private final String _abstract;
    public static final int _ABSTRACT = 1;
    private static final TField ABSTRACT_FIELD_DESC = new TField("abstract", TType.STRING, (short)1);
        private final String annotationWithQuote;
    public static final int _ANNOTATION_WITH_QUOTE = 3;
    private static final TField ANNOTATION_WITH_QUOTE_FIELD_DESC = new TField("annotation_with_quote", TType.STRING, (short)3);
        private final String class_;
    public static final int _CLASS_ = 4;
    private static final TField CLASS__FIELD_DESC = new TField("class_", TType.STRING, (short)4);
        private final String annotationWithTrailingComma;
    public static final int _ANNOTATION_WITH_TRAILING_COMMA = 5;
    private static final TField ANNOTATION_WITH_TRAILING_COMMA_FIELD_DESC = new TField("annotation_with_trailing_comma", TType.STRING, (short)5);
        private final String emptyAnnotations;
    public static final int _EMPTY_ANNOTATIONS = 6;
    private static final TField EMPTY_ANNOTATIONS_FIELD_DESC = new TField("empty_annotations", TType.STRING, (short)6);
        private final test.fixtures.basicannotations.MyEnum myEnum;
    public static final int _MY_ENUM = 7;
    private static final TField MY_ENUM_FIELD_DESC = new TField("my_enum", TType.I32, (short)7);
        private final List<String> cppTypeAnnotation;
    public static final int _CPP_TYPE_ANNOTATION = 8;
    private static final TField CPP_TYPE_ANNOTATION_FIELD_DESC = new TField("cpp_type_annotation", TType.LIST, (short)8);
        private final test.fixtures.basicannotations.MyUnion myUnion;
    public static final int _MY_UNION = 9;
    private static final TField MY_UNION_FIELD_DESC = new TField("my_union", TType.STRUCT, (short)9);
    static {
      NAMES_TO_IDS.put("major", 2);
      THRIFT_NAMES_TO_IDS.put("major", 2);
      FIELD_METADATA.put(2, MAJOR_FIELD_DESC);
      NAMES_TO_IDS.put("_abstract", 1);
      THRIFT_NAMES_TO_IDS.put("abstract", 1);
      FIELD_METADATA.put(1, ABSTRACT_FIELD_DESC);
      NAMES_TO_IDS.put("annotationWithQuote", 3);
      THRIFT_NAMES_TO_IDS.put("annotation_with_quote", 3);
      FIELD_METADATA.put(3, ANNOTATION_WITH_QUOTE_FIELD_DESC);
      NAMES_TO_IDS.put("class_", 4);
      THRIFT_NAMES_TO_IDS.put("class_", 4);
      FIELD_METADATA.put(4, CLASS__FIELD_DESC);
      NAMES_TO_IDS.put("annotationWithTrailingComma", 5);
      THRIFT_NAMES_TO_IDS.put("annotation_with_trailing_comma", 5);
      FIELD_METADATA.put(5, ANNOTATION_WITH_TRAILING_COMMA_FIELD_DESC);
      NAMES_TO_IDS.put("emptyAnnotations", 6);
      THRIFT_NAMES_TO_IDS.put("empty_annotations", 6);
      FIELD_METADATA.put(6, EMPTY_ANNOTATIONS_FIELD_DESC);
      NAMES_TO_IDS.put("myEnum", 7);
      THRIFT_NAMES_TO_IDS.put("my_enum", 7);
      FIELD_METADATA.put(7, MY_ENUM_FIELD_DESC);
      NAMES_TO_IDS.put("cppTypeAnnotation", 8);
      THRIFT_NAMES_TO_IDS.put("cpp_type_annotation", 8);
      FIELD_METADATA.put(8, CPP_TYPE_ANNOTATION_FIELD_DESC);
      NAMES_TO_IDS.put("myUnion", 9);
      THRIFT_NAMES_TO_IDS.put("my_union", 9);
      FIELD_METADATA.put(9, MY_UNION_FIELD_DESC);
      com.facebook.thrift.type.TypeRegistry.add(new com.facebook.thrift.type.Type(
        new com.facebook.thrift.type.UniversalName("facebook.com/thrift/compiler/test/fixtures/basic-annotations/src/module/MyStruct"),
        MyStruct.class, MyStruct::read0));
    }
    
    
    @com.facebook.swift.codec.ThriftField(value=2, name="major", requiredness=Requiredness.NONE)
    public long getMajor() { return major; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=1, name="abstract", requiredness=Requiredness.NONE)
    public String getAbstract() { return _abstract; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=3, name="annotation_with_quote", requiredness=Requiredness.NONE)
    public String getAnnotationWithQuote() { return annotationWithQuote; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=4, name="class_", requiredness=Requiredness.NONE)
    public String getClass_() { return class_; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=5, name="annotation_with_trailing_comma", requiredness=Requiredness.NONE)
    public String getAnnotationWithTrailingComma() { return annotationWithTrailingComma; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=6, name="empty_annotations", requiredness=Requiredness.NONE)
    public String getEmptyAnnotations() { return emptyAnnotations; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=7, name="my_enum", requiredness=Requiredness.NONE)
    public test.fixtures.basicannotations.MyEnum getMyEnum() { return myEnum; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=8, name="cpp_type_annotation", requiredness=Requiredness.NONE)
    public List<String> getCppTypeAnnotation() { return cppTypeAnnotation; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=9, name="my_union", requiredness=Requiredness.NONE)
    public test.fixtures.basicannotations.MyUnion getMyUnion() { return myUnion; }
    
    @java.lang.Override
    public String toString() {
        ToStringHelper helper = toStringHelper(this);
        helper.add("major", major);
        helper.add("_abstract", _abstract);
        helper.add("annotationWithQuote", annotationWithQuote);
        helper.add("class_", class_);
        helper.add("annotationWithTrailingComma", annotationWithTrailingComma);
        helper.add("emptyAnnotations", emptyAnnotations);
        helper.add("myEnum", myEnum);
        helper.add("cppTypeAnnotation", cppTypeAnnotation);
        helper.add("myUnion", myUnion);
        return helper.toString();
    }
    
    @java.lang.Override
    public boolean equals(java.lang.Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
    
        MyStruct other = (MyStruct)o;
    
        return
            Objects.equals(major, other.major) &&
            Objects.equals(_abstract, other._abstract) &&
            Objects.equals(annotationWithQuote, other.annotationWithQuote) &&
            Objects.equals(class_, other.class_) &&
            Objects.equals(annotationWithTrailingComma, other.annotationWithTrailingComma) &&
            Objects.equals(emptyAnnotations, other.emptyAnnotations) &&
            Objects.equals(myEnum, other.myEnum) &&
            Objects.equals(cppTypeAnnotation, other.cppTypeAnnotation) &&
            Objects.equals(myUnion, other.myUnion) &&
            true;
    }
    
    @java.lang.Override
    public int hashCode() {
        return Arrays.deepHashCode(new java.lang.Object[] {
            major,
            _abstract,
            annotationWithQuote,
            class_,
            annotationWithTrailingComma,
            emptyAnnotations,
            myEnum,
            cppTypeAnnotation,
            myUnion
        });
    }
    
    
    public static com.facebook.thrift.payload.Reader<MyStruct> asReader() {
      return MyStruct::read0;
    }
    
    public static MyStruct read0(TProtocol oprot) throws TException {
      TField __field;
      oprot.readStructBegin(MyStruct.NAMES_TO_IDS, MyStruct.THRIFT_NAMES_TO_IDS, MyStruct.FIELD_METADATA);
      MyStruct.Builder builder = new MyStruct.Builder();
      while (true) {
        __field = oprot.readFieldBegin();
        if (__field.type == TType.STOP) { break; }
        switch (__field.id) {
        case _MAJOR:
          if (__field.type == TType.I64) {
            long major = oprot.readI64();
            builder.setMajor(major);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _ABSTRACT:
          if (__field.type == TType.STRING) {
            String _abstract = oprot.readString();
            builder.setAbstract(_abstract);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _ANNOTATION_WITH_QUOTE:
          if (__field.type == TType.STRING) {
            String annotationWithQuote = oprot.readString();
            builder.setAnnotationWithQuote(annotationWithQuote);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _CLASS_:
          if (__field.type == TType.STRING) {
            String class_ = oprot.readString();
            builder.setClass_(class_);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _ANNOTATION_WITH_TRAILING_COMMA:
          if (__field.type == TType.STRING) {
            String annotationWithTrailingComma = oprot.readString();
            builder.setAnnotationWithTrailingComma(annotationWithTrailingComma);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _EMPTY_ANNOTATIONS:
          if (__field.type == TType.STRING) {
            String emptyAnnotations = oprot.readString();
            builder.setEmptyAnnotations(emptyAnnotations);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _MY_ENUM:
          if (__field.type == TType.I32) {
            test.fixtures.basicannotations.MyEnum myEnum = test.fixtures.basicannotations.MyEnum.fromInteger(oprot.readI32());
            builder.setMyEnum(myEnum);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _CPP_TYPE_ANNOTATION:
          if (__field.type == TType.LIST) {
            List<String> cppTypeAnnotation;
            {
            TList _list = oprot.readListBegin();
            cppTypeAnnotation = new ArrayList<String>(Math.max(0, _list.size));
            for (int _i = 0; (_list.size < 0) ? oprot.peekList() : (_i < _list.size); _i++) {
                
                String _value1 = oprot.readString();
                cppTypeAnnotation.add(_value1);
            }
            oprot.readListEnd();
            }
            builder.setCppTypeAnnotation(cppTypeAnnotation);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _MY_UNION:
          if (__field.type == TType.STRUCT) {
            test.fixtures.basicannotations.MyUnion myUnion = test.fixtures.basicannotations.MyUnion.read0(oprot);
            builder.setMyUnion(myUnion);
          } 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(MAJOR_FIELD_DESC);
      oprot.writeI64(this.major);
      oprot.writeFieldEnd();
      if (_abstract != null) {
        oprot.writeFieldBegin(ABSTRACT_FIELD_DESC);
        oprot.writeString(this._abstract);
        oprot.writeFieldEnd();
      }
      if (annotationWithQuote != null) {
        oprot.writeFieldBegin(ANNOTATION_WITH_QUOTE_FIELD_DESC);
        oprot.writeString(this.annotationWithQuote);
        oprot.writeFieldEnd();
      }
      if (class_ != null) {
        oprot.writeFieldBegin(CLASS__FIELD_DESC);
        oprot.writeString(this.class_);
        oprot.writeFieldEnd();
      }
      if (annotationWithTrailingComma != null) {
        oprot.writeFieldBegin(ANNOTATION_WITH_TRAILING_COMMA_FIELD_DESC);
        oprot.writeString(this.annotationWithTrailingComma);
        oprot.writeFieldEnd();
      }
      if (emptyAnnotations != null) {
        oprot.writeFieldBegin(EMPTY_ANNOTATIONS_FIELD_DESC);
        oprot.writeString(this.emptyAnnotations);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(MY_ENUM_FIELD_DESC);
      oprot.writeI32(this.myEnum == null ? 0 : com.facebook.thrift.util.EnumUtil.getValue(this.myEnum));
      oprot.writeFieldEnd();
      if (cppTypeAnnotation != null) {
        oprot.writeFieldBegin(CPP_TYPE_ANNOTATION_FIELD_DESC);
        List<String> _iter0 = cppTypeAnnotation;
        oprot.writeListBegin(new TList(TType.STRING, _iter0.size()));
        for (String _iter1 : _iter0) {
          oprot.writeString(_iter1);
        }
        oprot.writeListEnd();
        oprot.writeFieldEnd();
      }
      if (myUnion != null) {
        oprot.writeFieldBegin(MY_UNION_FIELD_DESC);
        this.myUnion.write0(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
    
    private static class _MyStructLazy {
        private static final MyStruct _DEFAULT = new MyStruct.Builder().build();
    }
    
    public static MyStruct defaultInstance() {
        return  _MyStructLazy._DEFAULT;
    }
}
