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

package test.fixtures.enums;

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=1, name="me2_3", requiredness=Requiredness.NONE) final test.fixtures.enums.MyEnum2 me23,
        @com.facebook.swift.codec.ThriftField(value=2, name="me3_n3", requiredness=Requiredness.NONE) final test.fixtures.enums.MyEnum3 me3N3,
        @com.facebook.swift.codec.ThriftField(value=4, name="me1_t1", requiredness=Requiredness.NONE) final test.fixtures.enums.MyEnum1 me1T1,
        @com.facebook.swift.codec.ThriftField(value=6, name="me1_t2", requiredness=Requiredness.NONE) final test.fixtures.enums.MyEnum1 me1T2
    ) {
        this.me23 = me23;
        this.me3N3 = me3N3;
        this.me1T1 = me1T1;
        this.me1T2 = me1T2;
    }
    
    @ThriftConstructor
    protected MyStruct() {
      this.me23 = test.fixtures.enums.MyEnum2.fromInteger(3);
      this.me3N3 = test.fixtures.enums.MyEnum3.fromInteger(-3);
      this.me1T1 = test.fixtures.enums.MyEnum1.ME1_1;
      this.me1T2 = test.fixtures.enums.MyEnum1.ME1_1;
    }
    
    public static Builder builder() {
      return new Builder();
    }

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

    public static class Builder {
        private test.fixtures.enums.MyEnum2 me23 = test.fixtures.enums.MyEnum2.fromInteger(3);
        private test.fixtures.enums.MyEnum3 me3N3 = test.fixtures.enums.MyEnum3.fromInteger(-3);
        private test.fixtures.enums.MyEnum1 me1T1 = test.fixtures.enums.MyEnum1.ME1_1;
        private test.fixtures.enums.MyEnum1 me1T2 = test.fixtures.enums.MyEnum1.ME1_1;
    
        @com.facebook.swift.codec.ThriftField(value=1, name="me2_3", requiredness=Requiredness.NONE)
        public Builder setMe23(test.fixtures.enums.MyEnum2 me23) {
            this.me23 = me23;
            return this;
        }
    
        public test.fixtures.enums.MyEnum2 getMe23() { return me23; }
    
            @com.facebook.swift.codec.ThriftField(value=2, name="me3_n3", requiredness=Requiredness.NONE)
        public Builder setMe3N3(test.fixtures.enums.MyEnum3 me3N3) {
            this.me3N3 = me3N3;
            return this;
        }
    
        public test.fixtures.enums.MyEnum3 getMe3N3() { return me3N3; }
    
            @com.facebook.swift.codec.ThriftField(value=4, name="me1_t1", requiredness=Requiredness.NONE)
        public Builder setMe1T1(test.fixtures.enums.MyEnum1 me1T1) {
            this.me1T1 = me1T1;
            return this;
        }
    
        public test.fixtures.enums.MyEnum1 getMe1T1() { return me1T1; }
    
            @com.facebook.swift.codec.ThriftField(value=6, name="me1_t2", requiredness=Requiredness.NONE)
        public Builder setMe1T2(test.fixtures.enums.MyEnum1 me1T2) {
            this.me1T2 = me1T2;
            return this;
        }
    
        public test.fixtures.enums.MyEnum1 getMe1T2() { return me1T2; }
    
        public Builder() { }
        public Builder(MyStruct other) {
            this.me23 = other.me23;
            this.me3N3 = other.me3N3;
            this.me1T1 = other.me1T1;
            this.me1T2 = other.me1T2;
        }
    
        @ThriftConstructor
        public MyStruct build() {
            MyStruct result = new MyStruct (
                this.me23,
                this.me3N3,
                this.me1T1,
                this.me1T2
            );
            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 test.fixtures.enums.MyEnum2 me23;
    public static final int _ME2_3 = 1;
    private static final TField ME2_3_FIELD_DESC = new TField("me2_3", TType.I32, (short)1);
        private final test.fixtures.enums.MyEnum3 me3N3;
    public static final int _ME3_N3 = 2;
    private static final TField ME3_N3_FIELD_DESC = new TField("me3_n3", TType.I32, (short)2);
        private final test.fixtures.enums.MyEnum1 me1T1;
    public static final int _ME1_T1 = 4;
    private static final TField ME1_T1_FIELD_DESC = new TField("me1_t1", TType.I32, (short)4);
        private final test.fixtures.enums.MyEnum1 me1T2;
    public static final int _ME1_T2 = 6;
    private static final TField ME1_T2_FIELD_DESC = new TField("me1_t2", TType.I32, (short)6);
    static {
      NAMES_TO_IDS.put("me23", 1);
      THRIFT_NAMES_TO_IDS.put("me2_3", 1);
      FIELD_METADATA.put(1, ME2_3_FIELD_DESC);
      NAMES_TO_IDS.put("me3N3", 2);
      THRIFT_NAMES_TO_IDS.put("me3_n3", 2);
      FIELD_METADATA.put(2, ME3_N3_FIELD_DESC);
      NAMES_TO_IDS.put("me1T1", 4);
      THRIFT_NAMES_TO_IDS.put("me1_t1", 4);
      FIELD_METADATA.put(4, ME1_T1_FIELD_DESC);
      NAMES_TO_IDS.put("me1T2", 6);
      THRIFT_NAMES_TO_IDS.put("me1_t2", 6);
      FIELD_METADATA.put(6, ME1_T2_FIELD_DESC);
      com.facebook.thrift.type.TypeRegistry.add(new com.facebook.thrift.type.Type(
        new com.facebook.thrift.type.UniversalName("test.dev/fixtures/enums/MyStruct"),
        MyStruct.class, MyStruct::read0));
    }
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=1, name="me2_3", requiredness=Requiredness.NONE)
    public test.fixtures.enums.MyEnum2 getMe23() { return me23; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=2, name="me3_n3", requiredness=Requiredness.NONE)
    public test.fixtures.enums.MyEnum3 getMe3N3() { return me3N3; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=4, name="me1_t1", requiredness=Requiredness.NONE)
    public test.fixtures.enums.MyEnum1 getMe1T1() { return me1T1; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=6, name="me1_t2", requiredness=Requiredness.NONE)
    public test.fixtures.enums.MyEnum1 getMe1T2() { return me1T2; }
    
    @java.lang.Override
    public String toString() {
        ToStringHelper helper = toStringHelper(this);
        helper.add("me23", me23);
        helper.add("me3N3", me3N3);
        helper.add("me1T1", me1T1);
        helper.add("me1T2", me1T2);
        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(me23, other.me23) &&
            Objects.equals(me3N3, other.me3N3) &&
            Objects.equals(me1T1, other.me1T1) &&
            Objects.equals(me1T2, other.me1T2) &&
            true;
    }
    
    @java.lang.Override
    public int hashCode() {
        return Arrays.deepHashCode(new java.lang.Object[] {
            me23,
            me3N3,
            me1T1,
            me1T2
        });
    }
    
    
    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 _ME2_3:
          if (__field.type == TType.I32) {
            test.fixtures.enums.MyEnum2 me23 = test.fixtures.enums.MyEnum2.fromInteger(oprot.readI32());
            builder.setMe23(me23);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _ME3_N3:
          if (__field.type == TType.I32) {
            test.fixtures.enums.MyEnum3 me3N3 = test.fixtures.enums.MyEnum3.fromInteger(oprot.readI32());
            builder.setMe3N3(me3N3);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _ME1_T1:
          if (__field.type == TType.I32) {
            test.fixtures.enums.MyEnum1 me1T1 = test.fixtures.enums.MyEnum1.fromInteger(oprot.readI32());
            builder.setMe1T1(me1T1);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _ME1_T2:
          if (__field.type == TType.I32) {
            test.fixtures.enums.MyEnum1 me1T2 = test.fixtures.enums.MyEnum1.fromInteger(oprot.readI32());
            builder.setMe1T2(me1T2);
          } 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(ME2_3_FIELD_DESC);
      oprot.writeI32(this.me23 == null ? 0 : com.facebook.thrift.util.EnumUtil.getValue(this.me23));
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(ME3_N3_FIELD_DESC);
      oprot.writeI32(this.me3N3 == null ? 0 : com.facebook.thrift.util.EnumUtil.getValue(this.me3N3));
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(ME1_T1_FIELD_DESC);
      oprot.writeI32(this.me1T1 == null ? 0 : com.facebook.thrift.util.EnumUtil.getValue(this.me1T1));
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(ME1_T2_FIELD_DESC);
      oprot.writeI32(this.me1T2 == null ? 0 : com.facebook.thrift.util.EnumUtil.getValue(this.me1T2));
      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;
    }
}
