001// Automatically generated by the Thrifty compiler; do not edit!
002// Generated on: 2023-01-16T22:12:20.362297582Z
003// Source: /home/ben/Development/ks-dexcount/src/main/thrift/PackageTree.thrift: (3, 1)
004package com.getkeepsafe.dexcount.thrift;
005
006import com.microsoft.thrifty.Adapter;
007import com.microsoft.thrifty.Struct;
008import com.microsoft.thrifty.StructBuilder;
009import com.microsoft.thrifty.TType;
010import com.microsoft.thrifty.ThriftField;
011import com.microsoft.thrifty.protocol.FieldMetadata;
012import com.microsoft.thrifty.protocol.ListMetadata;
013import com.microsoft.thrifty.protocol.Protocol;
014import com.microsoft.thrifty.util.ProtocolUtil;
015import java.io.IOException;
016import java.util.ArrayList;
017import java.util.Collections;
018import java.util.List;
019
020public final class MethodRef implements Struct {
021  public static final Adapter<MethodRef, Builder> ADAPTER = new MethodRefAdapter();
022
023  @ThriftField(
024      fieldId = 1
025  )
026  public final String declaringClass;
027
028  @ThriftField(
029      fieldId = 2
030  )
031  public final String returnType;
032
033  @ThriftField(
034      fieldId = 3
035  )
036  public final String methodName;
037
038  @ThriftField(
039      fieldId = 4
040  )
041  public final List<String> argumentTypes;
042
043  private MethodRef(Builder builder) {
044    this.declaringClass = builder.declaringClass;
045    this.returnType = builder.returnType;
046    this.methodName = builder.methodName;
047    this.argumentTypes = builder.argumentTypes == null ? null : Collections.unmodifiableList(builder.argumentTypes);
048  }
049
050  @Override
051  @SuppressWarnings("StringEquality")
052  public boolean equals(Object other) {
053    if (this == other) return true;
054    if (other == null) return false;
055    if (!(other instanceof MethodRef)) return false;
056    MethodRef that = (MethodRef) other;
057    return (this.declaringClass == that.declaringClass || (this.declaringClass != null && this.declaringClass.equals(that.declaringClass)))
058        && (this.returnType == that.returnType || (this.returnType != null && this.returnType.equals(that.returnType)))
059        && (this.methodName == that.methodName || (this.methodName != null && this.methodName.equals(that.methodName)))
060        && (this.argumentTypes == that.argumentTypes || (this.argumentTypes != null && this.argumentTypes.equals(that.argumentTypes)));
061  }
062
063  @Override
064  public int hashCode() {
065    int code = 16777619;
066    code ^= (this.declaringClass == null) ? 0 : this.declaringClass.hashCode();
067    code *= 0x811c9dc5;
068    code ^= (this.returnType == null) ? 0 : this.returnType.hashCode();
069    code *= 0x811c9dc5;
070    code ^= (this.methodName == null) ? 0 : this.methodName.hashCode();
071    code *= 0x811c9dc5;
072    code ^= (this.argumentTypes == null) ? 0 : this.argumentTypes.hashCode();
073    code *= 0x811c9dc5;
074    return code;
075  }
076
077  @Override
078  public String toString() {
079    return "MethodRef{declaringClass=" + this.declaringClass + ", returnType=" + this.returnType + ", methodName=" + this.methodName + ", argumentTypes=" + this.argumentTypes + "}";
080  }
081
082  @Override
083  public void write(Protocol protocol) throws IOException {
084    ADAPTER.write(protocol, this);
085  }
086
087  public static final class Builder implements StructBuilder<MethodRef> {
088    private String declaringClass;
089
090    private String returnType;
091
092    private String methodName;
093
094    private List<String> argumentTypes;
095
096    public Builder() {
097    }
098
099    public Builder(MethodRef struct) {
100      this.declaringClass = struct.declaringClass;
101      this.returnType = struct.returnType;
102      this.methodName = struct.methodName;
103      this.argumentTypes = struct.argumentTypes;
104    }
105
106    public Builder declaringClass(String declaringClass) {
107      this.declaringClass = declaringClass;
108      return this;
109    }
110
111    public Builder returnType(String returnType) {
112      this.returnType = returnType;
113      return this;
114    }
115
116    public Builder methodName(String methodName) {
117      this.methodName = methodName;
118      return this;
119    }
120
121    public Builder argumentTypes(List<String> argumentTypes) {
122      this.argumentTypes = argumentTypes;
123      return this;
124    }
125
126    @Override
127    public MethodRef build() {
128      return new MethodRef(this);
129    }
130
131    @Override
132    public void reset() {
133      this.declaringClass = null;
134      this.returnType = null;
135      this.methodName = null;
136      this.argumentTypes = null;
137    }
138  }
139
140  private static final class MethodRefAdapter implements Adapter<MethodRef, Builder> {
141    @Override
142    public void write(Protocol protocol, MethodRef struct) throws IOException {
143      protocol.writeStructBegin("MethodRef");
144      if (struct.declaringClass != null) {
145        protocol.writeFieldBegin("declaringClass", 1, TType.STRING);
146        protocol.writeString(struct.declaringClass);
147        protocol.writeFieldEnd();
148      }
149      if (struct.returnType != null) {
150        protocol.writeFieldBegin("returnType", 2, TType.STRING);
151        protocol.writeString(struct.returnType);
152        protocol.writeFieldEnd();
153      }
154      if (struct.methodName != null) {
155        protocol.writeFieldBegin("methodName", 3, TType.STRING);
156        protocol.writeString(struct.methodName);
157        protocol.writeFieldEnd();
158      }
159      if (struct.argumentTypes != null) {
160        protocol.writeFieldBegin("argumentTypes", 4, TType.LIST);
161        protocol.writeListBegin(TType.STRING, struct.argumentTypes.size());
162        for (String item0 : struct.argumentTypes) {
163          protocol.writeString(item0);
164        }
165        protocol.writeListEnd();
166        protocol.writeFieldEnd();
167      }
168      protocol.writeFieldStop();
169      protocol.writeStructEnd();
170    }
171
172    @Override
173    public MethodRef read(Protocol protocol, Builder builder) throws IOException {
174      protocol.readStructBegin();
175      while (true) {
176        FieldMetadata field = protocol.readFieldBegin();
177        if (field.typeId == TType.STOP) {
178          break;
179        }
180        switch (field.fieldId) {
181          case 1: {
182            if (field.typeId == TType.STRING) {
183              String value = protocol.readString();
184              builder.declaringClass(value);
185            } else {
186              ProtocolUtil.skip(protocol, field.typeId);
187            }
188          }
189          break;
190          case 2: {
191            if (field.typeId == TType.STRING) {
192              String value = protocol.readString();
193              builder.returnType(value);
194            } else {
195              ProtocolUtil.skip(protocol, field.typeId);
196            }
197          }
198          break;
199          case 3: {
200            if (field.typeId == TType.STRING) {
201              String value = protocol.readString();
202              builder.methodName(value);
203            } else {
204              ProtocolUtil.skip(protocol, field.typeId);
205            }
206          }
207          break;
208          case 4: {
209            if (field.typeId == TType.LIST) {
210              ListMetadata listMetadata0 = protocol.readListBegin();
211              List<String> value = new ArrayList<String>(listMetadata0.size);
212              for (int i0 = 0; i0 < listMetadata0.size; ++i0) {
213                String item0 = protocol.readString();
214                value.add(item0);
215              }
216              protocol.readListEnd();
217              builder.argumentTypes(value);
218            } else {
219              ProtocolUtil.skip(protocol, field.typeId);
220            }
221          }
222          break;
223          default: {
224            ProtocolUtil.skip(protocol, field.typeId);
225          }
226          break;
227        }
228        protocol.readFieldEnd();
229      }
230      protocol.readStructEnd();
231      return builder.build();
232    }
233
234    @Override
235    public MethodRef read(Protocol protocol) throws IOException {
236      return read(protocol, new Builder());
237    }
238  }
239}