001// Automatically generated by the Thrifty compiler; do not edit!
002// Generated on: 2021-05-17T06:20:27.420Z
003// Source: J:\facedb\facedb-service\FaceDb.thrift at 99:1
004package net.gdface.facedb.thrift.client;
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.Protocol;
013import com.microsoft.thrifty.util.ProtocolUtil;
014import java.io.IOException;
015import javax.annotation.Generated;
016import okio.ByteString;
017
018@Generated(
019    value = "com.microsoft.thrifty.gen.ThriftyCodeGenerator",
020    comments = "https://github.com/microsoft/thrifty"
021)
022public final class SearchResult implements Struct {
023  public static final Adapter<SearchResult, Builder> ADAPTER = new SearchResultAdapter();
024
025  @ThriftField(
026      fieldId = 1,
027      isOptional = true
028  )
029  public final ByteString featureId;
030
031  @ThriftField(
032      fieldId = 2,
033      isOptional = true
034  )
035  public final String hexFeatureId;
036
037  @ThriftField(
038      fieldId = 3,
039      isOptional = true
040  )
041  public final String owner;
042
043  @ThriftField(
044      fieldId = 4,
045      isRequired = true
046  )
047  public final Double similarity;
048
049  private SearchResult(Builder builder) {
050    this.featureId = builder.featureId;
051    this.hexFeatureId = builder.hexFeatureId;
052    this.owner = builder.owner;
053    this.similarity = builder.similarity;
054  }
055
056  @Override
057  @SuppressWarnings({"StringEquality", "NumberEquality"})
058  public boolean equals(Object other) {
059    if (this == other) return true;
060    if (other == null) return false;
061    if (!(other instanceof SearchResult)) return false;
062    SearchResult that = (SearchResult) other;
063    return (this.featureId == that.featureId || (this.featureId != null && this.featureId.equals(that.featureId)))
064        && (this.hexFeatureId == that.hexFeatureId || (this.hexFeatureId != null && this.hexFeatureId.equals(that.hexFeatureId)))
065        && (this.owner == that.owner || (this.owner != null && this.owner.equals(that.owner)))
066        && (this.similarity == that.similarity || this.similarity.equals(that.similarity));
067  }
068
069  @Override
070  public int hashCode() {
071    int code = 16777619;
072    code ^= (this.featureId == null) ? 0 : this.featureId.hashCode();
073    code *= 0x811c9dc5;
074    code ^= (this.hexFeatureId == null) ? 0 : this.hexFeatureId.hashCode();
075    code *= 0x811c9dc5;
076    code ^= (this.owner == null) ? 0 : this.owner.hashCode();
077    code *= 0x811c9dc5;
078    code ^= this.similarity.hashCode();
079    code *= 0x811c9dc5;
080    return code;
081  }
082
083  @Override
084  public String toString() {
085    return "SearchResult{featureId=" + this.featureId + ", hexFeatureId=" + this.hexFeatureId + ", owner=" + this.owner + ", similarity=" + this.similarity + "}";
086  }
087
088  @Override
089  public void write(Protocol protocol) throws IOException {
090    ADAPTER.write(protocol, this);
091  }
092
093  public static final class Builder implements StructBuilder<SearchResult> {
094    private ByteString featureId;
095
096    private String hexFeatureId;
097
098    private String owner;
099
100    private Double similarity;
101
102    public Builder() {
103    }
104
105    public Builder(SearchResult struct) {
106      this.featureId = struct.featureId;
107      this.hexFeatureId = struct.hexFeatureId;
108      this.owner = struct.owner;
109      this.similarity = struct.similarity;
110    }
111
112    public Builder featureId(ByteString featureId) {
113      this.featureId = featureId;
114      return this;
115    }
116
117    public Builder hexFeatureId(String hexFeatureId) {
118      this.hexFeatureId = hexFeatureId;
119      return this;
120    }
121
122    public Builder owner(String owner) {
123      this.owner = owner;
124      return this;
125    }
126
127    public Builder similarity(Double similarity) {
128      if (similarity == null) {
129        throw new NullPointerException("Required field 'similarity' cannot be null");
130      }
131      this.similarity = similarity;
132      return this;
133    }
134
135    @Override
136    public SearchResult build() {
137      if (this.similarity == null) {
138        throw new IllegalStateException("Required field 'similarity' is missing");
139      }
140      return new SearchResult(this);
141    }
142
143    @Override
144    public void reset() {
145      this.featureId = null;
146      this.hexFeatureId = null;
147      this.owner = null;
148      this.similarity = null;
149    }
150  }
151
152  private static final class SearchResultAdapter implements Adapter<SearchResult, Builder> {
153    @Override
154    public void write(Protocol protocol, SearchResult struct) throws IOException {
155      protocol.writeStructBegin("SearchResult");
156      if (struct.featureId != null) {
157        protocol.writeFieldBegin("featureId", 1, TType.STRING);
158        protocol.writeBinary(struct.featureId);
159        protocol.writeFieldEnd();
160      }
161      if (struct.hexFeatureId != null) {
162        protocol.writeFieldBegin("hexFeatureId", 2, TType.STRING);
163        protocol.writeString(struct.hexFeatureId);
164        protocol.writeFieldEnd();
165      }
166      if (struct.owner != null) {
167        protocol.writeFieldBegin("owner", 3, TType.STRING);
168        protocol.writeString(struct.owner);
169        protocol.writeFieldEnd();
170      }
171      protocol.writeFieldBegin("similarity", 4, TType.DOUBLE);
172      protocol.writeDouble(struct.similarity);
173      protocol.writeFieldEnd();
174      protocol.writeFieldStop();
175      protocol.writeStructEnd();
176    }
177
178    @Override
179    public SearchResult read(Protocol protocol, Builder builder) throws IOException {
180      protocol.readStructBegin();
181      while (true) {
182        FieldMetadata field = protocol.readFieldBegin();
183        if (field.typeId == TType.STOP) {
184          break;
185        }
186        switch (field.fieldId) {
187          case 1: {
188            if (field.typeId == TType.STRING) {
189              ByteString value = protocol.readBinary();
190              builder.featureId(value);
191            } else {
192              ProtocolUtil.skip(protocol, field.typeId);
193            }
194          }
195          break;
196          case 2: {
197            if (field.typeId == TType.STRING) {
198              String value = protocol.readString();
199              builder.hexFeatureId(value);
200            } else {
201              ProtocolUtil.skip(protocol, field.typeId);
202            }
203          }
204          break;
205          case 3: {
206            if (field.typeId == TType.STRING) {
207              String value = protocol.readString();
208              builder.owner(value);
209            } else {
210              ProtocolUtil.skip(protocol, field.typeId);
211            }
212          }
213          break;
214          case 4: {
215            if (field.typeId == TType.DOUBLE) {
216              double value = protocol.readDouble();
217              builder.similarity(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 SearchResult read(Protocol protocol) throws IOException {
236      return read(protocol, new Builder());
237    }
238  }
239}