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

zipkin2.proto3.Annotation 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.ReverseProtoWriter;
import com.squareup.wire.Syntax;
import com.squareup.wire.WireField;
import com.squareup.wire.internal.Internal;
import java.io.IOException;
import java.lang.Long;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.StringBuilder;
import java.util.Objects;
import okio.ByteString;

/**
 * Associates an event that explains latency with a timestamp.
 * Unlike log statements, annotations are often codes. Ex. "ws" for WireSend
 *
 * The next id is 3.
 */
public final class Annotation extends Message {
  public static final ProtoAdapter ADAPTER = new ProtoAdapter_Annotation();

  private static final long serialVersionUID = 0L;

  /**
   * Epoch microseconds of this event.
   *
   * For example, 1502787600000000 corresponds to 2017-08-15 09:00 UTC
   *
   * This value should be set directly by instrumentation, using the most
   * precise value possible. For example, gettimeofday or multiplying epoch
   * millis by 1000.
   */
  @WireField(
      tag = 1,
      adapter = "com.squareup.wire.ProtoAdapter#FIXED64",
      label = WireField.Label.OMIT_IDENTITY
  )
  public final long timestamp;

  /**
   * Usually a short tag indicating an event, like "error"
   *
   * While possible to add larger data, such as garbage collection details, low
   * cardinality event names both keep the size of spans down and also are easy
   * to search against.
   */
  @WireField(
      tag = 2,
      adapter = "com.squareup.wire.ProtoAdapter#STRING",
      label = WireField.Label.OMIT_IDENTITY
  )
  public final String value;

  public Annotation(long timestamp, String value) {
    this(timestamp, value, ByteString.EMPTY);
  }

  public Annotation(long timestamp, String value, ByteString unknownFields) {
    super(ADAPTER, unknownFields);
    this.timestamp = timestamp;
    if (value == null) {
      throw new IllegalArgumentException("value == null");
    }
    this.value = value;
  }

  @Override
  public Builder newBuilder() {
    Builder builder = new Builder();
    builder.timestamp = timestamp;
    builder.value = value;
    builder.addUnknownFields(unknownFields());
    return builder;
  }

  @Override
  public boolean equals(Object other) {
    if (other == this) return true;
    if (!(other instanceof Annotation)) return false;
    Annotation o = (Annotation) other;
    return unknownFields().equals(o.unknownFields())
        && Internal.equals(timestamp, o.timestamp)
        && Internal.equals(value, o.value);
  }

  @Override
  public int hashCode() {
    int result = super.hashCode;
    if (result == 0) {
      result = unknownFields().hashCode();
      result = result * 37 + Long.hashCode(timestamp);
      result = result * 37 + (value != null ? value.hashCode() : 0);
      super.hashCode = result;
    }
    return result;
  }

  @Override
  public String toString() {
    StringBuilder builder = new StringBuilder();
    builder.append(", timestamp=").append(timestamp);
    if (value != null) builder.append(", value=").append(Internal.sanitize(value));
    return builder.replace(0, 2, "Annotation{").append('}').toString();
  }

  public static final class Builder extends Message.Builder {
    public long timestamp;

    public String value;

    public Builder() {
      timestamp = 0L;
      value = "";
    }

    /**
     * Epoch microseconds of this event.
     *
     * For example, 1502787600000000 corresponds to 2017-08-15 09:00 UTC
     *
     * This value should be set directly by instrumentation, using the most
     * precise value possible. For example, gettimeofday or multiplying epoch
     * millis by 1000.
     */
    public Builder timestamp(long timestamp) {
      this.timestamp = timestamp;
      return this;
    }

    /**
     * Usually a short tag indicating an event, like "error"
     *
     * While possible to add larger data, such as garbage collection details, low
     * cardinality event names both keep the size of spans down and also are easy
     * to search against.
     */
    public Builder value(String value) {
      this.value = value;
      return this;
    }

    @Override
    public Annotation build() {
      return new Annotation(timestamp, value, super.buildUnknownFields());
    }
  }

  private static final class ProtoAdapter_Annotation extends ProtoAdapter {
    public ProtoAdapter_Annotation() {
      super(FieldEncoding.LENGTH_DELIMITED, Annotation.class, "type.googleapis.com/zipkin.proto3.Annotation", Syntax.PROTO_3, null, "zipkin.proto");
    }

    @Override
    public int encodedSize(Annotation value) {
      int result = 0;
      if (!Objects.equals(value.timestamp, 0L)) {
        result += ProtoAdapter.FIXED64.encodedSizeWithTag(1, value.timestamp);
      }
      if (!Objects.equals(value.value, "")) {
        result += ProtoAdapter.STRING.encodedSizeWithTag(2, value.value);
      }
      result += value.unknownFields().size();
      return result;
    }

    @Override
    public void encode(ProtoWriter writer, Annotation value) throws IOException {
      if (!Objects.equals(value.timestamp, 0L)) ProtoAdapter.FIXED64.encodeWithTag(writer, 1, value.timestamp);
      if (!Objects.equals(value.value, "")) ProtoAdapter.STRING.encodeWithTag(writer, 2, value.value);
      writer.writeBytes(value.unknownFields());
    }

    @Override
    public void encode(ReverseProtoWriter writer, Annotation value) throws IOException {
      writer.writeBytes(value.unknownFields());
      if (!Objects.equals(value.value, "")) ProtoAdapter.STRING.encodeWithTag(writer, 2, value.value);
      if (!Objects.equals(value.timestamp, 0L)) ProtoAdapter.FIXED64.encodeWithTag(writer, 1, value.timestamp);
    }

    @Override
    public Annotation 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.timestamp(ProtoAdapter.FIXED64.decode(reader)); break;
          case 2: builder.value(ProtoAdapter.STRING.decode(reader)); break;
          default: {
            reader.readUnknownField(tag);
          }
        }
      }
      builder.addUnknownFields(reader.endMessageAndGetUnknownFields(token));
      return builder.build();
    }

    @Override
    public Annotation redact(Annotation value) {
      Builder builder = value.newBuilder();
      builder.clearUnknownFields();
      return builder.build();
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy