zipkin2.proto3.Endpoint 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.Integer;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.StringBuilder;
import okio.ByteString;
/**
* The network context of a node in the service graph.
*
* The next id is 5.
*/
public final class Endpoint extends Message {
public static final ProtoAdapter ADAPTER = new ProtoAdapter_Endpoint();
private static final long serialVersionUID = 0L;
public static final String DEFAULT_SERVICE_NAME = "";
public static final ByteString DEFAULT_IPV4 = ByteString.EMPTY;
public static final ByteString DEFAULT_IPV6 = ByteString.EMPTY;
public static final Integer DEFAULT_PORT = 0;
/**
* Lower-case label of this node in the service graph, such as "favstar".
* Leave absent if unknown.
*
* This is a primary label for trace lookup and aggregation, so it should be
* intuitive and consistent. Many use a name from service discovery.
*/
@WireField(
tag = 1,
adapter = "com.squareup.wire.ProtoAdapter#STRING"
)
public final String service_name;
/**
* 4 byte representation of the primary IPv4 address associated with this
* connection. Absent if unknown.
*/
@WireField(
tag = 2,
adapter = "com.squareup.wire.ProtoAdapter#BYTES"
)
public final ByteString ipv4;
/**
* 16 byte representation of the primary IPv6 address associated with this
* connection. Absent if unknown.
*
* Prefer using the ipv4 field for mapped addresses.
*/
@WireField(
tag = 3,
adapter = "com.squareup.wire.ProtoAdapter#BYTES"
)
public final ByteString ipv6;
/**
* Depending on context, this could be a listen port or the client-side of a
* socket. Absent if unknown.
*/
@WireField(
tag = 4,
adapter = "com.squareup.wire.ProtoAdapter#INT32"
)
public final Integer port;
public Endpoint(String service_name, ByteString ipv4, ByteString ipv6, Integer port) {
this(service_name, ipv4, ipv6, port, ByteString.EMPTY);
}
public Endpoint(String service_name, ByteString ipv4, ByteString ipv6, Integer port,
ByteString unknownFields) {
super(ADAPTER, unknownFields);
this.service_name = service_name;
this.ipv4 = ipv4;
this.ipv6 = ipv6;
this.port = port;
}
@Override
public Builder newBuilder() {
Builder builder = new Builder();
builder.service_name = service_name;
builder.ipv4 = ipv4;
builder.ipv6 = ipv6;
builder.port = port;
builder.addUnknownFields(unknownFields());
return builder;
}
@Override
public boolean equals(Object other) {
if (other == this) return true;
if (!(other instanceof Endpoint)) return false;
Endpoint o = (Endpoint) other;
return unknownFields().equals(o.unknownFields())
&& Internal.equals(service_name, o.service_name)
&& Internal.equals(ipv4, o.ipv4)
&& Internal.equals(ipv6, o.ipv6)
&& Internal.equals(port, o.port);
}
@Override
public int hashCode() {
int result = super.hashCode;
if (result == 0) {
result = unknownFields().hashCode();
result = result * 37 + (service_name != null ? service_name.hashCode() : 0);
result = result * 37 + (ipv4 != null ? ipv4.hashCode() : 0);
result = result * 37 + (ipv6 != null ? ipv6.hashCode() : 0);
result = result * 37 + (port != null ? port.hashCode() : 0);
super.hashCode = result;
}
return result;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
if (service_name != null) builder.append(", service_name=").append(service_name);
if (ipv4 != null) builder.append(", ipv4=").append(ipv4);
if (ipv6 != null) builder.append(", ipv6=").append(ipv6);
if (port != null) builder.append(", port=").append(port);
return builder.replace(0, 2, "Endpoint{").append('}').toString();
}
public static final class Builder extends Message.Builder {
public String service_name;
public ByteString ipv4;
public ByteString ipv6;
public Integer port;
public Builder() {
}
/**
* Lower-case label of this node in the service graph, such as "favstar".
* Leave absent if unknown.
*
* This is a primary label for trace lookup and aggregation, so it should be
* intuitive and consistent. Many use a name from service discovery.
*/
public Builder service_name(String service_name) {
this.service_name = service_name;
return this;
}
/**
* 4 byte representation of the primary IPv4 address associated with this
* connection. Absent if unknown.
*/
public Builder ipv4(ByteString ipv4) {
this.ipv4 = ipv4;
return this;
}
/**
* 16 byte representation of the primary IPv6 address associated with this
* connection. Absent if unknown.
*
* Prefer using the ipv4 field for mapped addresses.
*/
public Builder ipv6(ByteString ipv6) {
this.ipv6 = ipv6;
return this;
}
/**
* Depending on context, this could be a listen port or the client-side of a
* socket. Absent if unknown.
*/
public Builder port(Integer port) {
this.port = port;
return this;
}
@Override
public Endpoint build() {
return new Endpoint(service_name, ipv4, ipv6, port, super.buildUnknownFields());
}
}
private static final class ProtoAdapter_Endpoint extends ProtoAdapter {
public ProtoAdapter_Endpoint() {
super(FieldEncoding.LENGTH_DELIMITED, Endpoint.class);
}
@Override
public int encodedSize(Endpoint value) {
return ProtoAdapter.STRING.encodedSizeWithTag(1, value.service_name)
+ ProtoAdapter.BYTES.encodedSizeWithTag(2, value.ipv4)
+ ProtoAdapter.BYTES.encodedSizeWithTag(3, value.ipv6)
+ ProtoAdapter.INT32.encodedSizeWithTag(4, value.port)
+ value.unknownFields().size();
}
@Override
public void encode(ProtoWriter writer, Endpoint value) throws IOException {
ProtoAdapter.STRING.encodeWithTag(writer, 1, value.service_name);
ProtoAdapter.BYTES.encodeWithTag(writer, 2, value.ipv4);
ProtoAdapter.BYTES.encodeWithTag(writer, 3, value.ipv6);
ProtoAdapter.INT32.encodeWithTag(writer, 4, value.port);
writer.writeBytes(value.unknownFields());
}
@Override
public Endpoint 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.service_name(ProtoAdapter.STRING.decode(reader)); break;
case 2: builder.ipv4(ProtoAdapter.BYTES.decode(reader)); break;
case 3: builder.ipv6(ProtoAdapter.BYTES.decode(reader)); break;
case 4: builder.port(ProtoAdapter.INT32.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 Endpoint redact(Endpoint value) {
Builder builder = value.newBuilder();
builder.clearUnknownFields();
return builder.build();
}
}
}