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

package test.fixtures.swift.enumstrict;

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="myEnum", requiredness=Requiredness.NONE) final test.fixtures.swift.enumstrict.MyEnum myEnum,
        @com.facebook.swift.codec.ThriftField(value=2, name="myBigEnum", requiredness=Requiredness.NONE) final test.fixtures.swift.enumstrict.MyBigEnum myBigEnum
    ) {
        this.myEnum = myEnum;
        this.myBigEnum = myBigEnum;
    }
    
    @ThriftConstructor
    protected MyStruct() {
      this.myEnum = test.fixtures.swift.enumstrict.MyEnum.fromInteger(0);
      this.myBigEnum = test.fixtures.swift.enumstrict.MyBigEnum.ONE;
    }
    
    public static Builder builder() {
      return new Builder();
    }

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

    public static class Builder {
        private test.fixtures.swift.enumstrict.MyEnum myEnum = test.fixtures.swift.enumstrict.MyEnum.fromInteger(0);
        private test.fixtures.swift.enumstrict.MyBigEnum myBigEnum = test.fixtures.swift.enumstrict.MyBigEnum.ONE;
    
        @com.facebook.swift.codec.ThriftField(value=1, name="myEnum", requiredness=Requiredness.NONE)
        public Builder setMyEnum(test.fixtures.swift.enumstrict.MyEnum myEnum) {
            this.myEnum = myEnum;
            return this;
        }
    
        public test.fixtures.swift.enumstrict.MyEnum getMyEnum() { return myEnum; }
    
            @com.facebook.swift.codec.ThriftField(value=2, name="myBigEnum", requiredness=Requiredness.NONE)
        public Builder setMyBigEnum(test.fixtures.swift.enumstrict.MyBigEnum myBigEnum) {
            this.myBigEnum = myBigEnum;
            return this;
        }
    
        public test.fixtures.swift.enumstrict.MyBigEnum getMyBigEnum() { return myBigEnum; }
    
        public Builder() { }
        public Builder(MyStruct other) {
            this.myEnum = other.myEnum;
            this.myBigEnum = other.myBigEnum;
        }
    
        @ThriftConstructor
        public MyStruct build() {
            MyStruct result = new MyStruct (
                this.myEnum,
                this.myBigEnum
            );
            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.swift.enumstrict.MyEnum myEnum;
    public static final int _MYENUM = 1;
    private static final TField MY_ENUM_FIELD_DESC = new TField("myEnum", TType.I32, (short)1);
        private final test.fixtures.swift.enumstrict.MyBigEnum myBigEnum;
    public static final int _MYBIGENUM = 2;
    private static final TField MY_BIG_ENUM_FIELD_DESC = new TField("myBigEnum", TType.I32, (short)2);
    static {
      NAMES_TO_IDS.put("myEnum", 1);
      THRIFT_NAMES_TO_IDS.put("myEnum", 1);
      FIELD_METADATA.put(1, MY_ENUM_FIELD_DESC);
      NAMES_TO_IDS.put("myBigEnum", 2);
      THRIFT_NAMES_TO_IDS.put("myBigEnum", 2);
      FIELD_METADATA.put(2, MY_BIG_ENUM_FIELD_DESC);
    }
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=1, name="myEnum", requiredness=Requiredness.NONE)
    public test.fixtures.swift.enumstrict.MyEnum getMyEnum() { return myEnum; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=2, name="myBigEnum", requiredness=Requiredness.NONE)
    public test.fixtures.swift.enumstrict.MyBigEnum getMyBigEnum() { return myBigEnum; }
    
    @java.lang.Override
    public String toString() {
        ToStringHelper helper = toStringHelper(this);
        helper.add("myEnum", myEnum);
        helper.add("myBigEnum", myBigEnum);
        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(myEnum, other.myEnum) &&
            Objects.equals(myBigEnum, other.myBigEnum) &&
            true;
    }
    
    @java.lang.Override
    public int hashCode() {
        return Arrays.deepHashCode(new java.lang.Object[] {
            myEnum,
            myBigEnum
        });
    }
    
    
    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 _MYENUM:
          if (__field.type == TType.I32) {
            test.fixtures.swift.enumstrict.MyEnum myEnum = test.fixtures.swift.enumstrict.MyEnum.fromInteger(oprot.readI32());
            builder.setMyEnum(myEnum);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _MYBIGENUM:
          if (__field.type == TType.I32) {
            test.fixtures.swift.enumstrict.MyBigEnum myBigEnum = test.fixtures.swift.enumstrict.MyBigEnum.fromInteger(oprot.readI32());
            builder.setMyBigEnum(myBigEnum);
          } 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(MY_ENUM_FIELD_DESC);
      oprot.writeI32(this.myEnum == null ? 0 : com.facebook.thrift.util.EnumUtil.getValue(this.myEnum));
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(MY_BIG_ENUM_FIELD_DESC);
      oprot.writeI32(this.myBigEnum == null ? 0 : com.facebook.thrift.util.EnumUtil.getValue(this.myBigEnum));
      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;
    }
}
