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

package test.fixtures.basic;

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="Containers", builder=Containers.Builder.class)
public final class Containers implements com.facebook.thrift.payload.ThriftSerializable {
    @ThriftConstructor
    public Containers(
        @com.facebook.swift.codec.ThriftField(value=1, name="I32List", requiredness=Requiredness.NONE) final List<Integer> i32List,
        @com.facebook.swift.codec.ThriftField(value=2, name="StringSet", requiredness=Requiredness.NONE) final Set<String> stringSet,
        @com.facebook.swift.codec.ThriftField(value=3, name="StringToI64Map", requiredness=Requiredness.NONE) final Map<String, Long> stringToI64Map
    ) {
        this.i32List = i32List;
        this.stringSet = stringSet;
        this.stringToI64Map = stringToI64Map;
    }
    
    @ThriftConstructor
    protected Containers() {
      this.i32List = null;
      this.stringSet = null;
      this.stringToI64Map = null;
    }
    
    public static Builder builder() {
      return new Builder();
    }

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

    public static class Builder {
        private List<Integer> i32List = null;
        private Set<String> stringSet = null;
        private Map<String, Long> stringToI64Map = null;
    
        @com.facebook.swift.codec.ThriftField(value=1, name="I32List", requiredness=Requiredness.NONE)
        public Builder setI32List(List<Integer> i32List) {
            this.i32List = i32List;
            return this;
        }
    
        public List<Integer> getI32List() { return i32List; }
    
            @com.facebook.swift.codec.ThriftField(value=2, name="StringSet", requiredness=Requiredness.NONE)
        public Builder setStringSet(Set<String> stringSet) {
            this.stringSet = stringSet;
            return this;
        }
    
        public Set<String> getStringSet() { return stringSet; }
    
            @com.facebook.swift.codec.ThriftField(value=3, name="StringToI64Map", requiredness=Requiredness.NONE)
        public Builder setStringToI64Map(Map<String, Long> stringToI64Map) {
            this.stringToI64Map = stringToI64Map;
            return this;
        }
    
        public Map<String, Long> getStringToI64Map() { return stringToI64Map; }
    
        public Builder() { }
        public Builder(Containers other) {
            this.i32List = other.i32List;
            this.stringSet = other.stringSet;
            this.stringToI64Map = other.stringToI64Map;
        }
    
        @ThriftConstructor
        public Containers build() {
            Containers result = new Containers (
                this.i32List,
                this.stringSet,
                this.stringToI64Map
            );
            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("Containers");
    private final List<Integer> i32List;
    public static final int _I32LIST = 1;
    private static final TField I32_LIST_FIELD_DESC = new TField("I32List", TType.LIST, (short)1);
        private final Set<String> stringSet;
    public static final int _STRINGSET = 2;
    private static final TField STRING_SET_FIELD_DESC = new TField("StringSet", TType.SET, (short)2);
        private final Map<String, Long> stringToI64Map;
    public static final int _STRINGTOI64MAP = 3;
    private static final TField STRING_TO_I64_MAP_FIELD_DESC = new TField("StringToI64Map", TType.MAP, (short)3);
    static {
      NAMES_TO_IDS.put("i32List", 1);
      THRIFT_NAMES_TO_IDS.put("I32List", 1);
      FIELD_METADATA.put(1, I32_LIST_FIELD_DESC);
      NAMES_TO_IDS.put("stringSet", 2);
      THRIFT_NAMES_TO_IDS.put("StringSet", 2);
      FIELD_METADATA.put(2, STRING_SET_FIELD_DESC);
      NAMES_TO_IDS.put("stringToI64Map", 3);
      THRIFT_NAMES_TO_IDS.put("StringToI64Map", 3);
      FIELD_METADATA.put(3, STRING_TO_I64_MAP_FIELD_DESC);
      com.facebook.thrift.type.TypeRegistry.add(new com.facebook.thrift.type.Type(
        new com.facebook.thrift.type.UniversalName("test.dev/fixtures/basic/Containers"),
        Containers.class, Containers::read0));
    }
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=1, name="I32List", requiredness=Requiredness.NONE)
    public List<Integer> getI32List() { return i32List; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=2, name="StringSet", requiredness=Requiredness.NONE)
    public Set<String> getStringSet() { return stringSet; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=3, name="StringToI64Map", requiredness=Requiredness.NONE)
    public Map<String, Long> getStringToI64Map() { return stringToI64Map; }
    
    @java.lang.Override
    public String toString() {
        ToStringHelper helper = toStringHelper(this);
        helper.add("i32List", i32List);
        helper.add("stringSet", stringSet);
        helper.add("stringToI64Map", stringToI64Map);
        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;
        }
    
        Containers other = (Containers)o;
    
        return
            Objects.equals(i32List, other.i32List) &&
            Objects.equals(stringSet, other.stringSet) &&
            Objects.equals(stringToI64Map, other.stringToI64Map) &&
            true;
    }
    
    @java.lang.Override
    public int hashCode() {
        return Arrays.deepHashCode(new java.lang.Object[] {
            i32List,
            stringSet,
            stringToI64Map
        });
    }
    
    
    public static com.facebook.thrift.payload.Reader<Containers> asReader() {
      return Containers::read0;
    }
    
    public static Containers read0(TProtocol oprot) throws TException {
      TField __field;
      oprot.readStructBegin(Containers.NAMES_TO_IDS, Containers.THRIFT_NAMES_TO_IDS, Containers.FIELD_METADATA);
      Containers.Builder builder = new Containers.Builder();
      while (true) {
        __field = oprot.readFieldBegin();
        if (__field.type == TType.STOP) { break; }
        switch (__field.id) {
        case _I32LIST:
          if (__field.type == TType.LIST) {
            List<Integer> i32List;
            {
            TList _list = oprot.readListBegin();
            i32List = new ArrayList<Integer>(Math.max(0, _list.size));
            for (int _i = 0; (_list.size < 0) ? oprot.peekList() : (_i < _list.size); _i++) {
                
                int _value1 = oprot.readI32();
                i32List.add(_value1);
            }
            oprot.readListEnd();
            }
            builder.setI32List(i32List);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _STRINGSET:
          if (__field.type == TType.SET) {
            Set<String> stringSet;
            {
            TSet _set = oprot.readSetBegin();
            stringSet = new HashSet<String>(Math.max(0, _set.size));
            for (int _i = 0; (_set.size < 0) ? oprot.peekSet() : (_i < _set.size); _i++) {
                
                String _value1 = oprot.readString();
                stringSet.add(_value1);
            }
            oprot.readSetEnd();
            }
            builder.setStringSet(stringSet);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _STRINGTOI64MAP:
          if (__field.type == TType.MAP) {
            Map<String, Long> stringToI64Map;
            {
            TMap _map = oprot.readMapBegin();
            stringToI64Map = new HashMap<String, Long>(Math.max(0, _map.size));
            for (int _i = 0; (_map.size < 0) ? oprot.peekMap() : (_i < _map.size); _i++) {
                
                String _key1 = oprot.readString();
                long _value1 = oprot.readI64();
                stringToI64Map.put(_key1, _value1);
            }
            }
            oprot.readMapEnd();
            builder.setStringToI64Map(stringToI64Map);
          } 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 (i32List != null) {
        oprot.writeFieldBegin(I32_LIST_FIELD_DESC);
        List<Integer> _iter0 = i32List;
        oprot.writeListBegin(new TList(TType.I32, _iter0.size()));
        for (int _iter1 : _iter0) {
          oprot.writeI32(_iter1);
        }
        oprot.writeListEnd();
        oprot.writeFieldEnd();
      }
      if (stringSet != null) {
        oprot.writeFieldBegin(STRING_SET_FIELD_DESC);
        Set<String> _iter0 = stringSet;
        oprot.writeSetBegin(new TSet(TType.STRING, _iter0.size()));
        for (String _iter1 : _iter0) {
          oprot.writeString(_iter1);
        }
        oprot.writeSetEnd();
        oprot.writeFieldEnd();
      }
      if (stringToI64Map != null) {
        oprot.writeFieldBegin(STRING_TO_I64_MAP_FIELD_DESC);
        Map<String, Long> _iter0 = stringToI64Map;
        oprot.writeMapBegin(new TMap(TType.STRING, TType.I64, _iter0.size()));
        for (Map.Entry<String, Long> _iter1 : _iter0.entrySet()) {
          oprot.writeString(_iter1.getKey());
          oprot.writeI64(_iter1.getValue());
        }
        oprot.writeMapEnd();
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
    
    private static class _ContainersLazy {
        private static final Containers _DEFAULT = new Containers.Builder().build();
    }
    
    public static Containers defaultInstance() {
        return  _ContainersLazy._DEFAULT;
    }
}
