org.glowroot.central.repo.ImmutableSyntheticMonitorKey Maven / Gradle / Ivy
package org.glowroot.central.repo;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;
import com.google.common.primitives.Longs;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.immutables.value.Generated;
/**
* Immutable implementation of {@link SyntheticMonitorIdDao.SyntheticMonitorKey}.
*
* Use the builder to create immutable instances:
* {@code ImmutableSyntheticMonitorKey.builder()}.
*/
@Generated(from = "SyntheticMonitorIdDao.SyntheticMonitorKey", generator = "Immutables")
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
@CheckReturnValue
final class ImmutableSyntheticMonitorKey
implements SyntheticMonitorIdDao.SyntheticMonitorKey {
private final String agentRollupId;
private final long captureTime;
private final String syntheticMonitorId;
private final String syntheticMonitorDisplay;
private ImmutableSyntheticMonitorKey(
String agentRollupId,
long captureTime,
String syntheticMonitorId,
String syntheticMonitorDisplay) {
this.agentRollupId = agentRollupId;
this.captureTime = captureTime;
this.syntheticMonitorId = syntheticMonitorId;
this.syntheticMonitorDisplay = syntheticMonitorDisplay;
}
/**
* @return The value of the {@code agentRollupId} attribute
*/
@JsonProperty("agentRollupId")
@Override
public String agentRollupId() {
return agentRollupId;
}
/**
* @return The value of the {@code captureTime} attribute
*/
@JsonProperty("captureTime")
@Override
public long captureTime() {
return captureTime;
}
/**
* @return The value of the {@code syntheticMonitorId} attribute
*/
@JsonProperty("syntheticMonitorId")
@Override
public String syntheticMonitorId() {
return syntheticMonitorId;
}
/**
* @return The value of the {@code syntheticMonitorDisplay} attribute
*/
@JsonProperty("syntheticMonitorDisplay")
@Override
public String syntheticMonitorDisplay() {
return syntheticMonitorDisplay;
}
/**
* Copy the current immutable object by setting a value for the {@link SyntheticMonitorIdDao.SyntheticMonitorKey#agentRollupId() agentRollupId} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for agentRollupId
* @return A modified copy of the {@code this} object
*/
public final ImmutableSyntheticMonitorKey withAgentRollupId(String value) {
String newValue = Objects.requireNonNull(value, "agentRollupId");
if (this.agentRollupId.equals(newValue)) return this;
return new ImmutableSyntheticMonitorKey(newValue, this.captureTime, this.syntheticMonitorId, this.syntheticMonitorDisplay);
}
/**
* Copy the current immutable object by setting a value for the {@link SyntheticMonitorIdDao.SyntheticMonitorKey#captureTime() captureTime} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for captureTime
* @return A modified copy of the {@code this} object
*/
public final ImmutableSyntheticMonitorKey withCaptureTime(long value) {
if (this.captureTime == value) return this;
return new ImmutableSyntheticMonitorKey(this.agentRollupId, value, this.syntheticMonitorId, this.syntheticMonitorDisplay);
}
/**
* Copy the current immutable object by setting a value for the {@link SyntheticMonitorIdDao.SyntheticMonitorKey#syntheticMonitorId() syntheticMonitorId} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for syntheticMonitorId
* @return A modified copy of the {@code this} object
*/
public final ImmutableSyntheticMonitorKey withSyntheticMonitorId(String value) {
String newValue = Objects.requireNonNull(value, "syntheticMonitorId");
if (this.syntheticMonitorId.equals(newValue)) return this;
return new ImmutableSyntheticMonitorKey(this.agentRollupId, this.captureTime, newValue, this.syntheticMonitorDisplay);
}
/**
* Copy the current immutable object by setting a value for the {@link SyntheticMonitorIdDao.SyntheticMonitorKey#syntheticMonitorDisplay() syntheticMonitorDisplay} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for syntheticMonitorDisplay
* @return A modified copy of the {@code this} object
*/
public final ImmutableSyntheticMonitorKey withSyntheticMonitorDisplay(String value) {
String newValue = Objects.requireNonNull(value, "syntheticMonitorDisplay");
if (this.syntheticMonitorDisplay.equals(newValue)) return this;
return new ImmutableSyntheticMonitorKey(this.agentRollupId, this.captureTime, this.syntheticMonitorId, newValue);
}
/**
* This instance is equal to all instances of {@code ImmutableSyntheticMonitorKey} that have equal attribute values.
* @return {@code true} if {@code this} is equal to {@code another} instance
*/
@Override
public boolean equals(@Nullable Object another) {
if (this == another) return true;
return another instanceof ImmutableSyntheticMonitorKey
&& equalTo((ImmutableSyntheticMonitorKey) another);
}
private boolean equalTo(ImmutableSyntheticMonitorKey another) {
return agentRollupId.equals(another.agentRollupId)
&& captureTime == another.captureTime
&& syntheticMonitorId.equals(another.syntheticMonitorId)
&& syntheticMonitorDisplay.equals(another.syntheticMonitorDisplay);
}
/**
* Computes a hash code from attributes: {@code agentRollupId}, {@code captureTime}, {@code syntheticMonitorId}, {@code syntheticMonitorDisplay}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + agentRollupId.hashCode();
h += (h << 5) + Longs.hashCode(captureTime);
h += (h << 5) + syntheticMonitorId.hashCode();
h += (h << 5) + syntheticMonitorDisplay.hashCode();
return h;
}
/**
* Prints the immutable value {@code SyntheticMonitorKey} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("SyntheticMonitorKey")
.omitNullValues()
.add("agentRollupId", agentRollupId)
.add("captureTime", captureTime)
.add("syntheticMonitorId", syntheticMonitorId)
.add("syntheticMonitorDisplay", syntheticMonitorDisplay)
.toString();
}
/**
* Utility type used to correctly read immutable object from JSON representation.
* @deprecated Do not use this type directly, it exists only for the Jackson-binding infrastructure
*/
@Generated(from = "SyntheticMonitorIdDao.SyntheticMonitorKey", generator = "Immutables")
@Deprecated
@SuppressWarnings("Immutable")
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements SyntheticMonitorIdDao.SyntheticMonitorKey {
@Nullable String agentRollupId;
long captureTime;
boolean captureTimeIsSet;
@Nullable String syntheticMonitorId;
@Nullable String syntheticMonitorDisplay;
@JsonProperty("agentRollupId")
public void setAgentRollupId(String agentRollupId) {
this.agentRollupId = agentRollupId;
}
@JsonProperty("captureTime")
public void setCaptureTime(long captureTime) {
this.captureTime = captureTime;
this.captureTimeIsSet = true;
}
@JsonProperty("syntheticMonitorId")
public void setSyntheticMonitorId(String syntheticMonitorId) {
this.syntheticMonitorId = syntheticMonitorId;
}
@JsonProperty("syntheticMonitorDisplay")
public void setSyntheticMonitorDisplay(String syntheticMonitorDisplay) {
this.syntheticMonitorDisplay = syntheticMonitorDisplay;
}
@Override
public String agentRollupId() { throw new UnsupportedOperationException(); }
@Override
public long captureTime() { throw new UnsupportedOperationException(); }
@Override
public String syntheticMonitorId() { throw new UnsupportedOperationException(); }
@Override
public String syntheticMonitorDisplay() { throw new UnsupportedOperationException(); }
}
/**
* @param json A JSON-bindable data structure
* @return An immutable value type
* @deprecated Do not use this method directly, it exists only for the Jackson-binding infrastructure
*/
@Deprecated
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
static ImmutableSyntheticMonitorKey fromJson(Json json) {
ImmutableSyntheticMonitorKey.Builder builder = ImmutableSyntheticMonitorKey.builder();
if (json.agentRollupId != null) {
builder.agentRollupId(json.agentRollupId);
}
if (json.captureTimeIsSet) {
builder.captureTime(json.captureTime);
}
if (json.syntheticMonitorId != null) {
builder.syntheticMonitorId(json.syntheticMonitorId);
}
if (json.syntheticMonitorDisplay != null) {
builder.syntheticMonitorDisplay(json.syntheticMonitorDisplay);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link SyntheticMonitorIdDao.SyntheticMonitorKey} value.
* Uses accessors to get values to initialize the new immutable instance.
* If an instance is already immutable, it is returned as is.
* @param instance The instance to copy
* @return A copied immutable SyntheticMonitorKey instance
*/
public static ImmutableSyntheticMonitorKey copyOf(SyntheticMonitorIdDao.SyntheticMonitorKey instance) {
if (instance instanceof ImmutableSyntheticMonitorKey) {
return (ImmutableSyntheticMonitorKey) instance;
}
return ImmutableSyntheticMonitorKey.builder()
.copyFrom(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableSyntheticMonitorKey ImmutableSyntheticMonitorKey}.
*
* ImmutableSyntheticMonitorKey.builder()
* .agentRollupId(String) // required {@link SyntheticMonitorIdDao.SyntheticMonitorKey#agentRollupId() agentRollupId}
* .captureTime(long) // required {@link SyntheticMonitorIdDao.SyntheticMonitorKey#captureTime() captureTime}
* .syntheticMonitorId(String) // required {@link SyntheticMonitorIdDao.SyntheticMonitorKey#syntheticMonitorId() syntheticMonitorId}
* .syntheticMonitorDisplay(String) // required {@link SyntheticMonitorIdDao.SyntheticMonitorKey#syntheticMonitorDisplay() syntheticMonitorDisplay}
* .build();
*
* @return A new ImmutableSyntheticMonitorKey builder
*/
public static ImmutableSyntheticMonitorKey.Builder builder() {
return new ImmutableSyntheticMonitorKey.Builder();
}
/**
* Builds instances of type {@link ImmutableSyntheticMonitorKey ImmutableSyntheticMonitorKey}.
* Initialize attributes and then invoke the {@link #build()} method to create an
* immutable instance.
* {@code Builder} is not thread-safe and generally should not be stored in a field or collection,
* but instead used immediately to create instances.
*/
@Generated(from = "SyntheticMonitorIdDao.SyntheticMonitorKey", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_AGENT_ROLLUP_ID = 0x1L;
private static final long INIT_BIT_CAPTURE_TIME = 0x2L;
private static final long INIT_BIT_SYNTHETIC_MONITOR_ID = 0x4L;
private static final long INIT_BIT_SYNTHETIC_MONITOR_DISPLAY = 0x8L;
private long initBits = 0xfL;
private @Nullable String agentRollupId;
private long captureTime;
private @Nullable String syntheticMonitorId;
private @Nullable String syntheticMonitorDisplay;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code SyntheticMonitorKey} instance.
* Regular attribute values will be replaced with those from the given instance.
* Absent optional values will not replace present values.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder copyFrom(SyntheticMonitorIdDao.SyntheticMonitorKey instance) {
Objects.requireNonNull(instance, "instance");
agentRollupId(instance.agentRollupId());
captureTime(instance.captureTime());
syntheticMonitorId(instance.syntheticMonitorId());
syntheticMonitorDisplay(instance.syntheticMonitorDisplay());
return this;
}
/**
* Initializes the value for the {@link SyntheticMonitorIdDao.SyntheticMonitorKey#agentRollupId() agentRollupId} attribute.
* @param agentRollupId The value for agentRollupId
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder agentRollupId(String agentRollupId) {
this.agentRollupId = Objects.requireNonNull(agentRollupId, "agentRollupId");
initBits &= ~INIT_BIT_AGENT_ROLLUP_ID;
return this;
}
/**
* Initializes the value for the {@link SyntheticMonitorIdDao.SyntheticMonitorKey#captureTime() captureTime} attribute.
* @param captureTime The value for captureTime
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder captureTime(long captureTime) {
this.captureTime = captureTime;
initBits &= ~INIT_BIT_CAPTURE_TIME;
return this;
}
/**
* Initializes the value for the {@link SyntheticMonitorIdDao.SyntheticMonitorKey#syntheticMonitorId() syntheticMonitorId} attribute.
* @param syntheticMonitorId The value for syntheticMonitorId
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder syntheticMonitorId(String syntheticMonitorId) {
this.syntheticMonitorId = Objects.requireNonNull(syntheticMonitorId, "syntheticMonitorId");
initBits &= ~INIT_BIT_SYNTHETIC_MONITOR_ID;
return this;
}
/**
* Initializes the value for the {@link SyntheticMonitorIdDao.SyntheticMonitorKey#syntheticMonitorDisplay() syntheticMonitorDisplay} attribute.
* @param syntheticMonitorDisplay The value for syntheticMonitorDisplay
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder syntheticMonitorDisplay(String syntheticMonitorDisplay) {
this.syntheticMonitorDisplay = Objects.requireNonNull(syntheticMonitorDisplay, "syntheticMonitorDisplay");
initBits &= ~INIT_BIT_SYNTHETIC_MONITOR_DISPLAY;
return this;
}
/**
* Builds a new {@link ImmutableSyntheticMonitorKey ImmutableSyntheticMonitorKey}.
* @return An immutable instance of SyntheticMonitorKey
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableSyntheticMonitorKey build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableSyntheticMonitorKey(agentRollupId, captureTime, syntheticMonitorId, syntheticMonitorDisplay);
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_AGENT_ROLLUP_ID) != 0) attributes.add("agentRollupId");
if ((initBits & INIT_BIT_CAPTURE_TIME) != 0) attributes.add("captureTime");
if ((initBits & INIT_BIT_SYNTHETIC_MONITOR_ID) != 0) attributes.add("syntheticMonitorId");
if ((initBits & INIT_BIT_SYNTHETIC_MONITOR_DISPLAY) != 0) attributes.add("syntheticMonitorDisplay");
return "Cannot build SyntheticMonitorKey, some of required attributes are not set " + attributes;
}
}
}