001// Automatically generated by the Thrifty compiler; do not edit!
002// Generated on: 2020-11-05T09:22:38.126Z
003// Source: J:\facelog\facelog-service\IFaceLog.thrift at 255:1
004package net.gdface.facelog.client.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.ThriftException;
011import com.microsoft.thrifty.ThriftField;
012import com.microsoft.thrifty.protocol.FieldMetadata;
013import com.microsoft.thrifty.protocol.Protocol;
014import com.microsoft.thrifty.util.ProtocolUtil;
015import java.io.IOException;
016import javax.annotation.Generated;
017
018@Generated(
019    value = "com.microsoft.thrifty.gen.ThriftyCodeGenerator",
020    comments = "https://github.com/microsoft/thrifty"
021)
022public final class Token implements Struct {
023  public static final Adapter<Token, Builder> ADAPTER = new TokenAdapter();
024
025  @ThriftField(
026      fieldId = 1,
027      isRequired = true
028  )
029  public final Integer id;
030
031  @ThriftField(
032      fieldId = 2,
033      isRequired = true
034  )
035  public final Integer t1;
036
037  @ThriftField(
038      fieldId = 3,
039      isRequired = true
040  )
041  public final Integer t2;
042
043  @ThriftField(
044      fieldId = 4,
045      isRequired = true
046  )
047  public final Integer t3;
048
049  @ThriftField(
050      fieldId = 5,
051      isRequired = true
052  )
053  public final Integer t4;
054
055  @ThriftField(
056      fieldId = 6,
057      isOptional = true
058  )
059  public final TokenType type;
060
061  private Token(Builder builder) {
062    this.id = builder.id;
063    this.t1 = builder.t1;
064    this.t2 = builder.t2;
065    this.t3 = builder.t3;
066    this.t4 = builder.t4;
067    this.type = builder.type;
068  }
069
070  @Override
071  @SuppressWarnings("NumberEquality")
072  public boolean equals(Object other) {
073    if (this == other) return true;
074    if (other == null) return false;
075    if (!(other instanceof Token)) return false;
076    Token that = (Token) other;
077    return (this.id == that.id || this.id.equals(that.id))
078        && (this.t1 == that.t1 || this.t1.equals(that.t1))
079        && (this.t2 == that.t2 || this.t2.equals(that.t2))
080        && (this.t3 == that.t3 || this.t3.equals(that.t3))
081        && (this.t4 == that.t4 || this.t4.equals(that.t4))
082        && (this.type == that.type || (this.type != null && this.type.equals(that.type)));
083  }
084
085  @Override
086  public int hashCode() {
087    int code = 16777619;
088    code ^= this.id.hashCode();
089    code *= 0x811c9dc5;
090    code ^= this.t1.hashCode();
091    code *= 0x811c9dc5;
092    code ^= this.t2.hashCode();
093    code *= 0x811c9dc5;
094    code ^= this.t3.hashCode();
095    code *= 0x811c9dc5;
096    code ^= this.t4.hashCode();
097    code *= 0x811c9dc5;
098    code ^= (this.type == null) ? 0 : this.type.hashCode();
099    code *= 0x811c9dc5;
100    return code;
101  }
102
103  @Override
104  public String toString() {
105    return "Token{id=" + this.id + ", t1=" + this.t1 + ", t2=" + this.t2 + ", t3=" + this.t3 + ", t4=" + this.t4 + ", type=" + this.type + "}";
106  }
107
108  @Override
109  public void write(Protocol protocol) throws IOException {
110    ADAPTER.write(protocol, this);
111  }
112
113  public static final class Builder implements StructBuilder<Token> {
114    private Integer id;
115
116    private Integer t1;
117
118    private Integer t2;
119
120    private Integer t3;
121
122    private Integer t4;
123
124    private TokenType type;
125
126    public Builder() {
127    }
128
129    public Builder(Token struct) {
130      this.id = struct.id;
131      this.t1 = struct.t1;
132      this.t2 = struct.t2;
133      this.t3 = struct.t3;
134      this.t4 = struct.t4;
135      this.type = struct.type;
136    }
137
138    public Builder id(Integer id) {
139      if (id == null) {
140        throw new NullPointerException("Required field 'id' cannot be null");
141      }
142      this.id = id;
143      return this;
144    }
145
146    public Builder t1(Integer t1) {
147      if (t1 == null) {
148        throw new NullPointerException("Required field 't1' cannot be null");
149      }
150      this.t1 = t1;
151      return this;
152    }
153
154    public Builder t2(Integer t2) {
155      if (t2 == null) {
156        throw new NullPointerException("Required field 't2' cannot be null");
157      }
158      this.t2 = t2;
159      return this;
160    }
161
162    public Builder t3(Integer t3) {
163      if (t3 == null) {
164        throw new NullPointerException("Required field 't3' cannot be null");
165      }
166      this.t3 = t3;
167      return this;
168    }
169
170    public Builder t4(Integer t4) {
171      if (t4 == null) {
172        throw new NullPointerException("Required field 't4' cannot be null");
173      }
174      this.t4 = t4;
175      return this;
176    }
177
178    public Builder type(TokenType type) {
179      this.type = type;
180      return this;
181    }
182
183    @Override
184    public Token build() {
185      if (this.id == null) {
186        throw new IllegalStateException("Required field 'id' is missing");
187      }
188      if (this.t1 == null) {
189        throw new IllegalStateException("Required field 't1' is missing");
190      }
191      if (this.t2 == null) {
192        throw new IllegalStateException("Required field 't2' is missing");
193      }
194      if (this.t3 == null) {
195        throw new IllegalStateException("Required field 't3' is missing");
196      }
197      if (this.t4 == null) {
198        throw new IllegalStateException("Required field 't4' is missing");
199      }
200      return new Token(this);
201    }
202
203    @Override
204    public void reset() {
205      this.id = null;
206      this.t1 = null;
207      this.t2 = null;
208      this.t3 = null;
209      this.t4 = null;
210      this.type = null;
211    }
212  }
213
214  private static final class TokenAdapter implements Adapter<Token, Builder> {
215    @Override
216    public void write(Protocol protocol, Token struct) throws IOException {
217      protocol.writeStructBegin("Token");
218      protocol.writeFieldBegin("id", 1, TType.I32);
219      protocol.writeI32(struct.id);
220      protocol.writeFieldEnd();
221      protocol.writeFieldBegin("t1", 2, TType.I32);
222      protocol.writeI32(struct.t1);
223      protocol.writeFieldEnd();
224      protocol.writeFieldBegin("t2", 3, TType.I32);
225      protocol.writeI32(struct.t2);
226      protocol.writeFieldEnd();
227      protocol.writeFieldBegin("t3", 4, TType.I32);
228      protocol.writeI32(struct.t3);
229      protocol.writeFieldEnd();
230      protocol.writeFieldBegin("t4", 5, TType.I32);
231      protocol.writeI32(struct.t4);
232      protocol.writeFieldEnd();
233      if (struct.type != null) {
234        protocol.writeFieldBegin("type", 6, TType.I32);
235        protocol.writeI32(struct.type.value);
236        protocol.writeFieldEnd();
237      }
238      protocol.writeFieldStop();
239      protocol.writeStructEnd();
240    }
241
242    @Override
243    public Token read(Protocol protocol, Builder builder) throws IOException {
244      protocol.readStructBegin();
245      while (true) {
246        FieldMetadata field = protocol.readFieldBegin();
247        if (field.typeId == TType.STOP) {
248          break;
249        }
250        switch (field.fieldId) {
251          case 1: {
252            if (field.typeId == TType.I32) {
253              int value = protocol.readI32();
254              builder.id(value);
255            } else {
256              ProtocolUtil.skip(protocol, field.typeId);
257            }
258          }
259          break;
260          case 2: {
261            if (field.typeId == TType.I32) {
262              int value = protocol.readI32();
263              builder.t1(value);
264            } else {
265              ProtocolUtil.skip(protocol, field.typeId);
266            }
267          }
268          break;
269          case 3: {
270            if (field.typeId == TType.I32) {
271              int value = protocol.readI32();
272              builder.t2(value);
273            } else {
274              ProtocolUtil.skip(protocol, field.typeId);
275            }
276          }
277          break;
278          case 4: {
279            if (field.typeId == TType.I32) {
280              int value = protocol.readI32();
281              builder.t3(value);
282            } else {
283              ProtocolUtil.skip(protocol, field.typeId);
284            }
285          }
286          break;
287          case 5: {
288            if (field.typeId == TType.I32) {
289              int value = protocol.readI32();
290              builder.t4(value);
291            } else {
292              ProtocolUtil.skip(protocol, field.typeId);
293            }
294          }
295          break;
296          case 6: {
297            if (field.typeId == TType.I32) {
298              int i32_0 = protocol.readI32();
299              net.gdface.facelog.client.thrift.TokenType value = net.gdface.facelog.client.thrift.TokenType.findByValue(i32_0);
300              if (value == null) {
301                throw new ThriftException(ThriftException.Kind.PROTOCOL_ERROR, "Unexpected value for enum-type TokenType: " + i32_0);
302              }
303              builder.type(value);
304            } else {
305              ProtocolUtil.skip(protocol, field.typeId);
306            }
307          }
308          break;
309          default: {
310            ProtocolUtil.skip(protocol, field.typeId);
311          }
312          break;
313        }
314        protocol.readFieldEnd();
315      }
316      protocol.readStructEnd();
317      return builder.build();
318    }
319
320    @Override
321    public Token read(Protocol protocol) throws IOException {
322      return read(protocol, new Builder());
323    }
324  }
325}