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

package test.fixtures.module2;

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="BigStruct", builder=BigStruct.Builder.class)
public final class BigStruct implements com.facebook.thrift.payload.ThriftSerializable {
    @ThriftConstructor
    public BigStruct(
        @com.facebook.swift.codec.ThriftField(value=1, name="s", requiredness=Requiredness.NONE) final test.fixtures.module2.Struct s,
        @com.facebook.swift.codec.ThriftField(value=2, name="id", requiredness=Requiredness.NONE) final int id
    ) {
        this.s = s;
        this.id = id;
    }
    
    @ThriftConstructor
    protected BigStruct() {
      this.s = null;
      this.id = 0;
    }
    
    public static Builder builder() {
      return new Builder();
    }

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

    public static class Builder {
        private test.fixtures.module2.Struct s = null;
        private int id = 0;
    
        @com.facebook.swift.codec.ThriftField(value=1, name="s", requiredness=Requiredness.NONE)
        public Builder setS(test.fixtures.module2.Struct s) {
            this.s = s;
            return this;
        }
    
        public test.fixtures.module2.Struct getS() { return s; }
    
            @com.facebook.swift.codec.ThriftField(value=2, name="id", requiredness=Requiredness.NONE)
        public Builder setId(int id) {
            this.id = id;
            return this;
        }
    
        public int getId() { return id; }
    
        public Builder() { }
        public Builder(BigStruct other) {
            this.s = other.s;
            this.id = other.id;
        }
    
        @ThriftConstructor
        public BigStruct build() {
            BigStruct result = new BigStruct (
                this.s,
                this.id
            );
            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("BigStruct");
    private final test.fixtures.module2.Struct s;
    public static final int _S = 1;
    private static final TField S_FIELD_DESC = new TField("s", TType.STRUCT, (short)1);
        private final int id;
    public static final int _ID = 2;
    private static final TField ID_FIELD_DESC = new TField("id", TType.I32, (short)2);
    static {
      NAMES_TO_IDS.put("s", 1);
      THRIFT_NAMES_TO_IDS.put("s", 1);
      FIELD_METADATA.put(1, S_FIELD_DESC);
      NAMES_TO_IDS.put("id", 2);
      THRIFT_NAMES_TO_IDS.put("id", 2);
      FIELD_METADATA.put(2, ID_FIELD_DESC);
    }
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=1, name="s", requiredness=Requiredness.NONE)
    public test.fixtures.module2.Struct getS() { return s; }
    
    
    
    @com.facebook.swift.codec.ThriftField(value=2, name="id", requiredness=Requiredness.NONE)
    public int getId() { return id; }
    
    @java.lang.Override
    public String toString() {
        ToStringHelper helper = toStringHelper(this);
        helper.add("s", s);
        helper.add("id", id);
        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;
        }
    
        BigStruct other = (BigStruct)o;
    
        return
            Objects.equals(s, other.s) &&
            Objects.equals(id, other.id) &&
            true;
    }
    
    @java.lang.Override
    public int hashCode() {
        return Arrays.deepHashCode(new java.lang.Object[] {
            s,
            id
        });
    }
    
    
    public static com.facebook.thrift.payload.Reader<BigStruct> asReader() {
      return BigStruct::read0;
    }
    
    public static BigStruct read0(TProtocol oprot) throws TException {
      TField __field;
      oprot.readStructBegin(BigStruct.NAMES_TO_IDS, BigStruct.THRIFT_NAMES_TO_IDS, BigStruct.FIELD_METADATA);
      BigStruct.Builder builder = new BigStruct.Builder();
      while (true) {
        __field = oprot.readFieldBegin();
        if (__field.type == TType.STOP) { break; }
        switch (__field.id) {
        case _S:
          if (__field.type == TType.STRUCT) {
            test.fixtures.module2.Struct s = test.fixtures.module2.Struct.read0(oprot);
            builder.setS(s);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _ID:
          if (__field.type == TType.I32) {
            int id = oprot.readI32();
            builder.setId(id);
          } 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);
      if (s != null) {
        oprot.writeFieldBegin(S_FIELD_DESC);
        this.s.write0(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(ID_FIELD_DESC);
      oprot.writeI32(this.id);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
    
    private static class _BigStructLazy {
        private static final BigStruct _DEFAULT = new BigStruct.Builder().build();
    }
    
    public static BigStruct defaultInstance() {
        return  _BigStructLazy._DEFAULT;
    }
}
