zipkin2.proto3.ListOfSpans Maven / Gradle / Ivy
The newest version!
// Code generated by Wire protocol buffer compiler, do not edit.
// Source file: zipkin.proto
package zipkin2.proto3;
import com.squareup.wire.FieldEncoding;
import com.squareup.wire.Message;
import com.squareup.wire.ProtoAdapter;
import com.squareup.wire.ProtoReader;
import com.squareup.wire.ProtoWriter;
import com.squareup.wire.WireField;
import com.squareup.wire.internal.Internal;
import java.io.IOException;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.StringBuilder;
import java.util.List;
import okio.ByteString;
/**
* A list of spans with possibly different trace ids, in no particular order.
*
* This is used for all transports: POST, Kafka messages etc. No other fields
* are expected, This message facilitates the mechanics of encoding a list, as
* a field number is required. The name of this type is the same in the OpenApi
* aka Swagger specification. https://zipkin.io/zipkin-api/#/default/post_spans
*/
public final class ListOfSpans extends Message {
public static final ProtoAdapter ADAPTER = new ProtoAdapter_ListOfSpans();
private static final long serialVersionUID = 0L;
@WireField(
tag = 1,
adapter = "zipkin2.proto3.Span#ADAPTER",
label = WireField.Label.REPEATED
)
public final List spans;
public ListOfSpans(List spans) {
this(spans, ByteString.EMPTY);
}
public ListOfSpans(List spans, ByteString unknownFields) {
super(ADAPTER, unknownFields);
this.spans = Internal.immutableCopyOf("spans", spans);
}
@Override
public Builder newBuilder() {
Builder builder = new Builder();
builder.spans = Internal.copyOf("spans", spans);
builder.addUnknownFields(unknownFields());
return builder;
}
@Override
public boolean equals(Object other) {
if (other == this) return true;
if (!(other instanceof ListOfSpans)) return false;
ListOfSpans o = (ListOfSpans) other;
return unknownFields().equals(o.unknownFields())
&& spans.equals(o.spans);
}
@Override
public int hashCode() {
int result = super.hashCode;
if (result == 0) {
result = unknownFields().hashCode();
result = result * 37 + spans.hashCode();
super.hashCode = result;
}
return result;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
if (!spans.isEmpty()) builder.append(", spans=").append(spans);
return builder.replace(0, 2, "ListOfSpans{").append('}').toString();
}
public static final class Builder extends Message.Builder {
public List spans;
public Builder() {
spans = Internal.newMutableList();
}
public Builder spans(List spans) {
Internal.checkElementsNotNull(spans);
this.spans = spans;
return this;
}
@Override
public ListOfSpans build() {
return new ListOfSpans(spans, super.buildUnknownFields());
}
}
private static final class ProtoAdapter_ListOfSpans extends ProtoAdapter {
public ProtoAdapter_ListOfSpans() {
super(FieldEncoding.LENGTH_DELIMITED, ListOfSpans.class);
}
@Override
public int encodedSize(ListOfSpans value) {
return Span.ADAPTER.asRepeated().encodedSizeWithTag(1, value.spans)
+ value.unknownFields().size();
}
@Override
public void encode(ProtoWriter writer, ListOfSpans value) throws IOException {
Span.ADAPTER.asRepeated().encodeWithTag(writer, 1, value.spans);
writer.writeBytes(value.unknownFields());
}
@Override
public ListOfSpans decode(ProtoReader reader) throws IOException {
Builder builder = new Builder();
long token = reader.beginMessage();
for (int tag; (tag = reader.nextTag()) != -1;) {
switch (tag) {
case 1: builder.spans.add(Span.ADAPTER.decode(reader)); break;
default: {
FieldEncoding fieldEncoding = reader.peekFieldEncoding();
Object value = fieldEncoding.rawProtoAdapter().decode(reader);
builder.addUnknownField(tag, fieldEncoding, value);
}
}
}
reader.endMessage(token);
return builder.build();
}
@Override
public ListOfSpans redact(ListOfSpans value) {
Builder builder = value.newBuilder();
Internal.redactElements(builder.spans, Span.ADAPTER);
builder.clearUnknownFields();
return builder.build();
}
}
}