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

package test.fixtures.annotation;

import com.facebook.swift.codec.*;
import com.facebook.swift.codec.ThriftField.Requiredness;
import com.facebook.swift.codec.ThriftField.Recursiveness;
import java.util.*;
import javax.annotation.Nullable;
import org.apache.thrift.*;
import org.apache.thrift.transport.*;
import org.apache.thrift.protocol.*;
import com.google.common.collect.*;

@SwiftGenerated
@com.facebook.swift.codec.ThriftStruct("Unfortunate_exception")
public final class UnfortunateException extends org.apache.thrift.TBaseException implements com.facebook.thrift.payload.ThriftSerializable {
    private static final long serialVersionUID = 1L;

    
    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("Unfortunate_exception");
    private final String anSnakeString;
    public static final int _AN_SNAKE_STRING = 1;
    private static final TField AN_SNAKE_STRING_FIELD_DESC = new TField("an_snake_string", TType.STRING, (short)1);
    private final int aCamelI32;
    public static final int _ACAMELI32 = 2;
    private static final TField A_CAMEL_I32_FIELD_DESC = new TField("aCamelI32", TType.I32, (short)2);

    static {
      NAMES_TO_IDS.put("anSnakeString", 1);
      THRIFT_NAMES_TO_IDS.put("an_snake_string", 1);
      FIELD_METADATA.put(1, AN_SNAKE_STRING_FIELD_DESC);
      NAMES_TO_IDS.put("aCamelI32", 2);
      THRIFT_NAMES_TO_IDS.put("aCamelI32", 2);
      FIELD_METADATA.put(2, A_CAMEL_I32_FIELD_DESC);
    }

    @ThriftConstructor
    public UnfortunateException(
        @com.facebook.swift.codec.ThriftField(value=1, name="an_snake_string", requiredness=Requiredness.NONE) final String anSnakeString,
        @com.facebook.swift.codec.ThriftField(value=2, name="aCamelI32", requiredness=Requiredness.NONE) final int aCamelI32
    ) {
        this.anSnakeString = anSnakeString;
        this.aCamelI32 = aCamelI32;
    }
    
    @ThriftConstructor
    protected UnfortunateException() {
      this.anSnakeString = null;
      this.aCamelI32 = 0;
    }
    
    public static class Builder {
        private String anSnakeString = null;
        private int aCamelI32 = 0;
    
        @com.facebook.swift.codec.ThriftField(value=1, name="an_snake_string", requiredness=Requiredness.NONE)
        public Builder setAnSnakeString(String anSnakeString) {
            this.anSnakeString = anSnakeString;
            return this;
        }
    
        public String getAnSnakeString() { return anSnakeString; }
    
            @com.facebook.swift.codec.ThriftField(value=2, name="aCamelI32", requiredness=Requiredness.NONE)
        public Builder setACamelI32(int aCamelI32) {
            this.aCamelI32 = aCamelI32;
            return this;
        }
    
        public int getACamelI32() { return aCamelI32; }
    
        public Builder() { }
        public Builder(UnfortunateException other) {
            this.anSnakeString = other.anSnakeString;
            this.aCamelI32 = other.aCamelI32;
        }
    
        @ThriftConstructor
        public UnfortunateException build() {
            UnfortunateException result = new UnfortunateException (
                this.anSnakeString,
                this.aCamelI32
            );
            return result;
        }
    }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=1, name="an_snake_string", requiredness=Requiredness.NONE)
    public String getAnSnakeString() { return anSnakeString; }
        
    
    @com.facebook.swift.codec.ThriftField(value=2, name="aCamelI32", requiredness=Requiredness.NONE)
    public int getACamelI32() { return aCamelI32; }
    
    
    public static com.facebook.thrift.payload.Reader<UnfortunateException> asReader() {
      return UnfortunateException::read0;
    }
    
    public static UnfortunateException read0(TProtocol oprot) throws TException {
      TField __field;
      oprot.readStructBegin(UnfortunateException.NAMES_TO_IDS, UnfortunateException.THRIFT_NAMES_TO_IDS, UnfortunateException.FIELD_METADATA);
      UnfortunateException.Builder builder = new UnfortunateException.Builder();
      while (true) {
        __field = oprot.readFieldBegin();
        if (__field.type == TType.STOP) { break; }
        switch (__field.id) {
        case _AN_SNAKE_STRING:
          if (__field.type == TType.STRING) {
            String anSnakeString = oprot.readString();
            builder.setAnSnakeString(anSnakeString);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _ACAMELI32:
          if (__field.type == TType.I32) {
            int aCamelI32 = oprot.readI32();
            builder.setACamelI32(aCamelI32);
          } 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 (anSnakeString != null) {
        oprot.writeFieldBegin(AN_SNAKE_STRING_FIELD_DESC);
        oprot.writeString(this.anSnakeString);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(A_CAMEL_I32_FIELD_DESC);
      oprot.writeI32(this.aCamelI32);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
    
    private static class _UnfortunateExceptionLazy {
        private static final UnfortunateException _DEFAULT = new UnfortunateException.Builder().build();
    }
    
    public static UnfortunateException defaultInstance() {
        return  _UnfortunateExceptionLazy._DEFAULT;
    }}
