events.CounterEvent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snotel Show documentation
Show all versions of snotel Show documentation
Java support for Cloud Foundry's Loggregator using the Dropsonde protocol.
// Code generated by Wire protocol buffer compiler, do not edit.
// Source file: /Users/mheath/projects/snotel/target/checkout/client/src/main/proto/events/metric.proto
package events;
import com.squareup.wire.Message;
import com.squareup.wire.ProtoField;
import static com.squareup.wire.Message.Datatype.STRING;
import static com.squareup.wire.Message.Datatype.UINT64;
import static com.squareup.wire.Message.Label.REQUIRED;
/**
* / A CounterEvent represents the increment of a counter. It contains only the change in the value; it is the responsibility of downstream consumers to maintain the value of the counter.
*/
public final class CounterEvent extends Message {
public static final String DEFAULT_NAME = "";
public static final Long DEFAULT_DELTA = 0L;
public static final Long DEFAULT_TOTAL = 0L;
@ProtoField(tag = 1, type = STRING, label = REQUIRED)
public final String name;
/**
* / Name of the counter. Must be consistent for downstream consumers to associate events semantically.
*/
@ProtoField(tag = 2, type = UINT64, label = REQUIRED)
public final Long delta;
/**
* / Amount by which to increment the counter.
*/
@ProtoField(tag = 3, type = UINT64)
public final Long total;
public CounterEvent(String name, Long delta, Long total) {
this.name = name;
this.delta = delta;
this.total = total;
}
private CounterEvent(Builder builder) {
this(builder.name, builder.delta, builder.total);
setBuilder(builder);
}
@Override
public boolean equals(Object other) {
if (other == this) return true;
if (!(other instanceof CounterEvent)) return false;
CounterEvent o = (CounterEvent) other;
return equals(name, o.name)
&& equals(delta, o.delta)
&& equals(total, o.total);
}
@Override
public int hashCode() {
int result = hashCode;
if (result == 0) {
result = name != null ? name.hashCode() : 0;
result = result * 37 + (delta != null ? delta.hashCode() : 0);
result = result * 37 + (total != null ? total.hashCode() : 0);
hashCode = result;
}
return result;
}
public static final class Builder extends Message.Builder {
public String name;
public Long delta;
public Long total;
public Builder() {
}
public Builder(CounterEvent message) {
super(message);
if (message == null) return;
this.name = message.name;
this.delta = message.delta;
this.total = message.total;
}
public Builder name(String name) {
this.name = name;
return this;
}
/**
* / Name of the counter. Must be consistent for downstream consumers to associate events semantically.
*/
public Builder delta(Long delta) {
this.delta = delta;
return this;
}
/**
* / Amount by which to increment the counter.
*/
public Builder total(Long total) {
this.total = total;
return this;
}
@Override
public CounterEvent build() {
checkRequiredFields();
return new CounterEvent(this);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy