All Downloads are FREE. Search and download functionalities are using the official Maven repository.

zipkin2.proto3.ListOfSpans Maven / Gradle / Ivy

There is a newer version: 3.4.2
Show 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.ReverseProtoWriter;
import com.squareup.wire.Syntax;
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);
    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, "type.googleapis.com/zipkin.proto3.ListOfSpans", Syntax.PROTO_3, null, "zipkin.proto");
    }

    @Override
    public int encodedSize(ListOfSpans value) {
      int result = 0;
      result += Span.ADAPTER.asRepeated().encodedSizeWithTag(1, value.spans);
      result += value.unknownFields().size();
      return result;
    }

    @Override
    public void encode(ProtoWriter writer, ListOfSpans value) throws IOException {
      Span.ADAPTER.asRepeated().encodeWithTag(writer, 1, value.spans);
      writer.writeBytes(value.unknownFields());
    }

    @Override
    public void encode(ReverseProtoWriter writer, ListOfSpans value) throws IOException {
      writer.writeBytes(value.unknownFields());
      Span.ADAPTER.asRepeated().encodeWithTag(writer, 1, value.spans);
    }

    @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: {
            reader.readUnknownField(tag);
          }
        }
      }
      builder.addUnknownFields(reader.endMessageAndGetUnknownFields(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();
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy