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

package test.fixtures.adapter;

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="Person", builder=Person.Builder.class)
public final class Person implements com.facebook.thrift.payload.ThriftSerializable {
    @ThriftConstructor
    public Person(
        @com.facebook.swift.codec.ThriftField(value=1, name="name", requiredness=Requiredness.NONE) final String name
    ) {
        this.name = name;
    }
    
    @ThriftConstructor
    protected Person() {
      this.name = null;
    }
    
    public static class Builder {
        private String name = null;
    
        @com.facebook.swift.codec.ThriftField(value=1, name="name", requiredness=Requiredness.NONE)
        public Builder setName(String name) {
            this.name = name;
            return this;
        }
    
        public String getName() { return name; }
    
        public Builder() { }
        public Builder(Person other) {
            this.name = other.name;
        }
    
        @ThriftConstructor
        public Person build() {
            Person result = new Person (
                this.name
            );
            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("Person");
    private final String name;
    public static final int _NAME = 1;
    private static final TField NAME_FIELD_DESC = new TField("name", TType.STRING, (short)1);
    static {
      NAMES_TO_IDS.put("name", 1);
      THRIFT_NAMES_TO_IDS.put("name", 1);
      FIELD_METADATA.put(1, NAME_FIELD_DESC);
      com.facebook.thrift.type.TypeRegistry.add(new com.facebook.thrift.type.Type(
        new com.facebook.thrift.type.UniversalName("facebook.com/thrift/test/Person"),
        Person.class, Person::read0));
    }
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=1, name="name", requiredness=Requiredness.NONE)
    public String getName() { return name; }
    
    @java.lang.Override
    public String toString() {
        ToStringHelper helper = toStringHelper(this);
        helper.add("name", name);
        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;
        }
    
        Person other = (Person)o;
    
        return
            Objects.equals(name, other.name) &&
            true;
    }
    
    @java.lang.Override
    public int hashCode() {
        return Arrays.deepHashCode(new java.lang.Object[] {
            name
        });
    }
    
    
    public static com.facebook.thrift.payload.Reader<Person> asReader() {
      return Person::read0;
    }
    
    public static Person read0(TProtocol oprot) throws TException {
      TField __field;
      oprot.readStructBegin(Person.NAMES_TO_IDS, Person.THRIFT_NAMES_TO_IDS, Person.FIELD_METADATA);
      Person.Builder builder = new Person.Builder();
      while (true) {
        __field = oprot.readFieldBegin();
        if (__field.type == TType.STOP) { break; }
        switch (__field.id) {
        case _NAME:
          if (__field.type == TType.STRING) {
            String name = oprot.readString();
            builder.setName(name);
          } 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 (name != null) {
        oprot.writeFieldBegin(NAME_FIELD_DESC);
        oprot.writeString(this.name);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
    
    private static class _PersonLazy {
        private static final Person _DEFAULT = new Person.Builder().build();
    }
    
    public static Person defaultInstance() {
        return  _PersonLazy._DEFAULT;
    }
}
