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

package test.fixtures.refs;

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="StructWithContainers", builder=StructWithContainers.Builder.class)
public final class StructWithContainers implements com.facebook.thrift.payload.ThriftSerializable {
    @ThriftConstructor
    public StructWithContainers(
        @com.facebook.swift.codec.ThriftField(value=1, name="list_ref", requiredness=Requiredness.NONE) final List<Integer> listRef,
        @com.facebook.swift.codec.ThriftField(value=2, name="set_ref", requiredness=Requiredness.NONE) final Set<Integer> setRef,
        @com.facebook.swift.codec.ThriftField(value=3, name="map_ref", requiredness=Requiredness.NONE) final Map<Integer, Integer> mapRef,
        @com.facebook.swift.codec.ThriftField(value=4, name="list_ref_unique", requiredness=Requiredness.NONE) final List<Integer> listRefUnique,
        @com.facebook.swift.codec.ThriftField(value=5, name="set_ref_shared", requiredness=Requiredness.NONE) final Set<Integer> setRefShared,
        @com.facebook.swift.codec.ThriftField(value=6, name="list_ref_shared_const", requiredness=Requiredness.NONE) final List<Integer> listRefSharedConst
    ) {
        this.listRef = listRef;
        this.setRef = setRef;
        this.mapRef = mapRef;
        this.listRefUnique = listRefUnique;
        this.setRefShared = setRefShared;
        this.listRefSharedConst = listRefSharedConst;
    }
    
    @ThriftConstructor
    protected StructWithContainers() {
      this.listRef = null;
      this.setRef = null;
      this.mapRef = null;
      this.listRefUnique = null;
      this.setRefShared = null;
      this.listRefSharedConst = null;
    }
    
    public static Builder builder() {
      return new Builder();
    }

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

    public static class Builder {
        private List<Integer> listRef = null;
        private Set<Integer> setRef = null;
        private Map<Integer, Integer> mapRef = null;
        private List<Integer> listRefUnique = null;
        private Set<Integer> setRefShared = null;
        private List<Integer> listRefSharedConst = null;
    
        @com.facebook.swift.codec.ThriftField(value=1, name="list_ref", requiredness=Requiredness.NONE)
        public Builder setListRef(List<Integer> listRef) {
            this.listRef = listRef;
            return this;
        }
    
        public List<Integer> getListRef() { return listRef; }
    
            @com.facebook.swift.codec.ThriftField(value=2, name="set_ref", requiredness=Requiredness.NONE)
        public Builder setSetRef(Set<Integer> setRef) {
            this.setRef = setRef;
            return this;
        }
    
        public Set<Integer> getSetRef() { return setRef; }
    
            @com.facebook.swift.codec.ThriftField(value=3, name="map_ref", requiredness=Requiredness.NONE)
        public Builder setMapRef(Map<Integer, Integer> mapRef) {
            this.mapRef = mapRef;
            return this;
        }
    
        public Map<Integer, Integer> getMapRef() { return mapRef; }
    
            @com.facebook.swift.codec.ThriftField(value=4, name="list_ref_unique", requiredness=Requiredness.NONE)
        public Builder setListRefUnique(List<Integer> listRefUnique) {
            this.listRefUnique = listRefUnique;
            return this;
        }
    
        public List<Integer> getListRefUnique() { return listRefUnique; }
    
            @com.facebook.swift.codec.ThriftField(value=5, name="set_ref_shared", requiredness=Requiredness.NONE)
        public Builder setSetRefShared(Set<Integer> setRefShared) {
            this.setRefShared = setRefShared;
            return this;
        }
    
        public Set<Integer> getSetRefShared() { return setRefShared; }
    
            @com.facebook.swift.codec.ThriftField(value=6, name="list_ref_shared_const", requiredness=Requiredness.NONE)
        public Builder setListRefSharedConst(List<Integer> listRefSharedConst) {
            this.listRefSharedConst = listRefSharedConst;
            return this;
        }
    
        public List<Integer> getListRefSharedConst() { return listRefSharedConst; }
    
        public Builder() { }
        public Builder(StructWithContainers other) {
            this.listRef = other.listRef;
            this.setRef = other.setRef;
            this.mapRef = other.mapRef;
            this.listRefUnique = other.listRefUnique;
            this.setRefShared = other.setRefShared;
            this.listRefSharedConst = other.listRefSharedConst;
        }
    
        @ThriftConstructor
        public StructWithContainers build() {
            StructWithContainers result = new StructWithContainers (
                this.listRef,
                this.setRef,
                this.mapRef,
                this.listRefUnique,
                this.setRefShared,
                this.listRefSharedConst
            );
            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("StructWithContainers");
    private final List<Integer> listRef;
    public static final int _LIST_REF = 1;
    private static final TField LIST_REF_FIELD_DESC = new TField("list_ref", TType.LIST, (short)1);
        private final Set<Integer> setRef;
    public static final int _SET_REF = 2;
    private static final TField SET_REF_FIELD_DESC = new TField("set_ref", TType.SET, (short)2);
        private final Map<Integer, Integer> mapRef;
    public static final int _MAP_REF = 3;
    private static final TField MAP_REF_FIELD_DESC = new TField("map_ref", TType.MAP, (short)3);
        private final List<Integer> listRefUnique;
    public static final int _LIST_REF_UNIQUE = 4;
    private static final TField LIST_REF_UNIQUE_FIELD_DESC = new TField("list_ref_unique", TType.LIST, (short)4);
        private final Set<Integer> setRefShared;
    public static final int _SET_REF_SHARED = 5;
    private static final TField SET_REF_SHARED_FIELD_DESC = new TField("set_ref_shared", TType.SET, (short)5);
        private final List<Integer> listRefSharedConst;
    public static final int _LIST_REF_SHARED_CONST = 6;
    private static final TField LIST_REF_SHARED_CONST_FIELD_DESC = new TField("list_ref_shared_const", TType.LIST, (short)6);
    static {
      NAMES_TO_IDS.put("listRef", 1);
      THRIFT_NAMES_TO_IDS.put("list_ref", 1);
      FIELD_METADATA.put(1, LIST_REF_FIELD_DESC);
      NAMES_TO_IDS.put("setRef", 2);
      THRIFT_NAMES_TO_IDS.put("set_ref", 2);
      FIELD_METADATA.put(2, SET_REF_FIELD_DESC);
      NAMES_TO_IDS.put("mapRef", 3);
      THRIFT_NAMES_TO_IDS.put("map_ref", 3);
      FIELD_METADATA.put(3, MAP_REF_FIELD_DESC);
      NAMES_TO_IDS.put("listRefUnique", 4);
      THRIFT_NAMES_TO_IDS.put("list_ref_unique", 4);
      FIELD_METADATA.put(4, LIST_REF_UNIQUE_FIELD_DESC);
      NAMES_TO_IDS.put("setRefShared", 5);
      THRIFT_NAMES_TO_IDS.put("set_ref_shared", 5);
      FIELD_METADATA.put(5, SET_REF_SHARED_FIELD_DESC);
      NAMES_TO_IDS.put("listRefSharedConst", 6);
      THRIFT_NAMES_TO_IDS.put("list_ref_shared_const", 6);
      FIELD_METADATA.put(6, LIST_REF_SHARED_CONST_FIELD_DESC);
    }
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=1, name="list_ref", requiredness=Requiredness.NONE)
    public List<Integer> getListRef() { return listRef; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=2, name="set_ref", requiredness=Requiredness.NONE)
    public Set<Integer> getSetRef() { return setRef; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=3, name="map_ref", requiredness=Requiredness.NONE)
    public Map<Integer, Integer> getMapRef() { return mapRef; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=4, name="list_ref_unique", requiredness=Requiredness.NONE)
    public List<Integer> getListRefUnique() { return listRefUnique; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=5, name="set_ref_shared", requiredness=Requiredness.NONE)
    public Set<Integer> getSetRefShared() { return setRefShared; }
    
    
    @Nullable
    @com.facebook.swift.codec.ThriftField(value=6, name="list_ref_shared_const", requiredness=Requiredness.NONE)
    public List<Integer> getListRefSharedConst() { return listRefSharedConst; }
    
    @java.lang.Override
    public String toString() {
        ToStringHelper helper = toStringHelper(this);
        helper.add("listRef", listRef);
        helper.add("setRef", setRef);
        helper.add("mapRef", mapRef);
        helper.add("listRefUnique", listRefUnique);
        helper.add("setRefShared", setRefShared);
        helper.add("listRefSharedConst", listRefSharedConst);
        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;
        }
    
        StructWithContainers other = (StructWithContainers)o;
    
        return
            Objects.equals(listRef, other.listRef) &&
            Objects.equals(setRef, other.setRef) &&
            Objects.equals(mapRef, other.mapRef) &&
            Objects.equals(listRefUnique, other.listRefUnique) &&
            Objects.equals(setRefShared, other.setRefShared) &&
            Objects.equals(listRefSharedConst, other.listRefSharedConst) &&
            true;
    }
    
    @java.lang.Override
    public int hashCode() {
        return Arrays.deepHashCode(new java.lang.Object[] {
            listRef,
            setRef,
            mapRef,
            listRefUnique,
            setRefShared,
            listRefSharedConst
        });
    }
    
    
    public static com.facebook.thrift.payload.Reader<StructWithContainers> asReader() {
      return StructWithContainers::read0;
    }
    
    public static StructWithContainers read0(TProtocol oprot) throws TException {
      TField __field;
      oprot.readStructBegin(StructWithContainers.NAMES_TO_IDS, StructWithContainers.THRIFT_NAMES_TO_IDS, StructWithContainers.FIELD_METADATA);
      StructWithContainers.Builder builder = new StructWithContainers.Builder();
      while (true) {
        __field = oprot.readFieldBegin();
        if (__field.type == TType.STOP) { break; }
        switch (__field.id) {
        case _LIST_REF:
          if (__field.type == TType.LIST) {
            List<Integer> listRef;
            {
            TList _list = oprot.readListBegin();
            listRef = 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();
                listRef.add(_value1);
            }
            oprot.readListEnd();
            }
            builder.setListRef(listRef);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _SET_REF:
          if (__field.type == TType.SET) {
            Set<Integer> setRef;
            {
            TSet _set = oprot.readSetBegin();
            setRef = new HashSet<Integer>(Math.max(0, _set.size));
            for (int _i = 0; (_set.size < 0) ? oprot.peekSet() : (_i < _set.size); _i++) {
                
                int _value1 = oprot.readI32();
                setRef.add(_value1);
            }
            oprot.readSetEnd();
            }
            builder.setSetRef(setRef);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _MAP_REF:
          if (__field.type == TType.MAP) {
            Map<Integer, Integer> mapRef;
            {
            TMap _map = oprot.readMapBegin();
            mapRef = new HashMap<Integer, Integer>(Math.max(0, _map.size));
            for (int _i = 0; (_map.size < 0) ? oprot.peekMap() : (_i < _map.size); _i++) {
                
                int _key1 = oprot.readI32();
                int _value1 = oprot.readI32();
                mapRef.put(_key1, _value1);
            }
            }
            oprot.readMapEnd();
            builder.setMapRef(mapRef);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _LIST_REF_UNIQUE:
          if (__field.type == TType.LIST) {
            List<Integer> listRefUnique;
            {
            TList _list = oprot.readListBegin();
            listRefUnique = 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();
                listRefUnique.add(_value1);
            }
            oprot.readListEnd();
            }
            builder.setListRefUnique(listRefUnique);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _SET_REF_SHARED:
          if (__field.type == TType.SET) {
            Set<Integer> setRefShared;
            {
            TSet _set = oprot.readSetBegin();
            setRefShared = new HashSet<Integer>(Math.max(0, _set.size));
            for (int _i = 0; (_set.size < 0) ? oprot.peekSet() : (_i < _set.size); _i++) {
                
                int _value1 = oprot.readI32();
                setRefShared.add(_value1);
            }
            oprot.readSetEnd();
            }
            builder.setSetRefShared(setRefShared);
          } else {
            TProtocolUtil.skip(oprot, __field.type);
          }
          break;
        case _LIST_REF_SHARED_CONST:
          if (__field.type == TType.LIST) {
            List<Integer> listRefSharedConst;
            {
            TList _list = oprot.readListBegin();
            listRefSharedConst = 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();
                listRefSharedConst.add(_value1);
            }
            oprot.readListEnd();
            }
            builder.setListRefSharedConst(listRefSharedConst);
          } 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 (listRef != null) {
        oprot.writeFieldBegin(LIST_REF_FIELD_DESC);
        List<Integer> _iter0 = listRef;
        oprot.writeListBegin(new TList(TType.I32, _iter0.size()));
        for (int _iter1 : _iter0) {
          oprot.writeI32(_iter1);
        }
        oprot.writeListEnd();
        oprot.writeFieldEnd();
      }
      if (setRef != null) {
        oprot.writeFieldBegin(SET_REF_FIELD_DESC);
        Set<Integer> _iter0 = setRef;
        oprot.writeSetBegin(new TSet(TType.I32, _iter0.size()));
        for (int _iter1 : _iter0) {
          oprot.writeI32(_iter1);
        }
        oprot.writeSetEnd();
        oprot.writeFieldEnd();
      }
      if (mapRef != null) {
        oprot.writeFieldBegin(MAP_REF_FIELD_DESC);
        Map<Integer, Integer> _iter0 = mapRef;
        oprot.writeMapBegin(new TMap(TType.I32, TType.I32, _iter0.size()));
        for (Map.Entry<Integer, Integer> _iter1 : _iter0.entrySet()) {
          oprot.writeI32(_iter1.getKey());
          oprot.writeI32(_iter1.getValue());
        }
        oprot.writeMapEnd();
        oprot.writeFieldEnd();
      }
      if (listRefUnique != null) {
        oprot.writeFieldBegin(LIST_REF_UNIQUE_FIELD_DESC);
        List<Integer> _iter0 = listRefUnique;
        oprot.writeListBegin(new TList(TType.I32, _iter0.size()));
        for (int _iter1 : _iter0) {
          oprot.writeI32(_iter1);
        }
        oprot.writeListEnd();
        oprot.writeFieldEnd();
      }
      if (setRefShared != null) {
        oprot.writeFieldBegin(SET_REF_SHARED_FIELD_DESC);
        Set<Integer> _iter0 = setRefShared;
        oprot.writeSetBegin(new TSet(TType.I32, _iter0.size()));
        for (int _iter1 : _iter0) {
          oprot.writeI32(_iter1);
        }
        oprot.writeSetEnd();
        oprot.writeFieldEnd();
      }
      if (listRefSharedConst != null) {
        oprot.writeFieldBegin(LIST_REF_SHARED_CONST_FIELD_DESC);
        List<Integer> _iter0 = listRefSharedConst;
        oprot.writeListBegin(new TList(TType.I32, _iter0.size()));
        for (int _iter1 : _iter0) {
          oprot.writeI32(_iter1);
        }
        oprot.writeListEnd();
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
    
    private static class _StructWithContainersLazy {
        private static final StructWithContainers _DEFAULT = new StructWithContainers.Builder().build();
    }
    
    public static StructWithContainers defaultInstance() {
        return  _StructWithContainersLazy._DEFAULT;
    }
}
