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

org.cloudfoundry.dropsonde.events.UUID Maven / Gradle / Ivy

There is a newer version: 5.12.2.RELEASE
Show newest version
// Code generated by Wire protocol buffer compiler, do not edit.
// Source file: uuid.proto
package org.cloudfoundry.dropsonde.events;

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.Long;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.StringBuilder;
import okio.ByteString;

/**
 * / Type representing a 128-bit UUID.
 *
 * The bytes of the UUID should be packed in little-endian **byte** (not bit) order. For example, the UUID `f47ac10b-58cc-4372-a567-0e02b2c3d479` should be encoded as `UUID{ low: 0x7243cc580bc17af4, high: 0x79d4c3b2020e67a5 }`
 */
public final class UUID extends Message {
  public static final ProtoAdapter ADAPTER = new ProtoAdapter_UUID();

  private static final long serialVersionUID = 0L;

  public static final Long DEFAULT_LOW = 0L;

  public static final Long DEFAULT_HIGH = 0L;

  @WireField(
      tag = 1,
      adapter = "com.squareup.wire.ProtoAdapter#UINT64",
      label = WireField.Label.REQUIRED
  )
  public final Long low;

  @WireField(
      tag = 2,
      adapter = "com.squareup.wire.ProtoAdapter#UINT64",
      label = WireField.Label.REQUIRED
  )
  public final Long high;

  public UUID(Long low, Long high) {
    this(low, high, ByteString.EMPTY);
  }

  public UUID(Long low, Long high, ByteString unknownFields) {
    super(ADAPTER, unknownFields);
    this.low = low;
    this.high = high;
  }

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

  @Override
  public boolean equals(Object other) {
    if (other == this) return true;
    if (!(other instanceof UUID)) return false;
    UUID o = (UUID) other;
    return unknownFields().equals(o.unknownFields())
        && low.equals(o.low)
        && high.equals(o.high);
  }

  @Override
  public int hashCode() {
    int result = super.hashCode;
    if (result == 0) {
      result = unknownFields().hashCode();
      result = result * 37 + low.hashCode();
      result = result * 37 + high.hashCode();
      super.hashCode = result;
    }
    return result;
  }

  @Override
  public String toString() {
    StringBuilder builder = new StringBuilder();
    builder.append(", low=").append(low);
    builder.append(", high=").append(high);
    return builder.replace(0, 2, "UUID{").append('}').toString();
  }

  public static final class Builder extends Message.Builder {
    public Long low;

    public Long high;

    public Builder() {
    }

    public Builder low(Long low) {
      this.low = low;
      return this;
    }

    public Builder high(Long high) {
      this.high = high;
      return this;
    }

    @Override
    public UUID build() {
      if (low == null
          || high == null) {
        throw Internal.missingRequiredFields(low, "low",
            high, "high");
      }
      return new UUID(low, high, super.buildUnknownFields());
    }
  }

  private static final class ProtoAdapter_UUID extends ProtoAdapter {
    public ProtoAdapter_UUID() {
      super(FieldEncoding.LENGTH_DELIMITED, UUID.class);
    }

    @Override
    public int encodedSize(UUID value) {
      return ProtoAdapter.UINT64.encodedSizeWithTag(1, value.low)
          + ProtoAdapter.UINT64.encodedSizeWithTag(2, value.high)
          + value.unknownFields().size();
    }

    @Override
    public void encode(ProtoWriter writer, UUID value) throws IOException {
      ProtoAdapter.UINT64.encodeWithTag(writer, 1, value.low);
      ProtoAdapter.UINT64.encodeWithTag(writer, 2, value.high);
      writer.writeBytes(value.unknownFields());
    }

    @Override
    public UUID 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.low(ProtoAdapter.UINT64.decode(reader)); break;
          case 2: builder.high(ProtoAdapter.UINT64.decode(reader)); break;
          default: {
            reader.readUnknownField(tag);
          }
        }
      }
      builder.addUnknownFields(reader.endMessageAndGetUnknownFields(token));
      return builder.build();
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy