org.glowroot.central.repo.ImmutableNeedsRollupKey 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.io.Serializable;
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 GaugeValueDaoImpl.NeedsRollupKey}.
*
* Use the builder to create immutable instances:
* {@code ImmutableNeedsRollupKey.builder()}.
* Use the static factory method to create immutable instances:
* {@code ImmutableNeedsRollupKey.of()}.
*/
@Generated(from = "GaugeValueDaoImpl.NeedsRollupKey", generator = "Immutables")
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
@CheckReturnValue
final class ImmutableNeedsRollupKey
implements GaugeValueDaoImpl.NeedsRollupKey {
private final String agentRollupId;
private final long captureTime;
private ImmutableNeedsRollupKey(String agentRollupId, long captureTime) {
this.agentRollupId = Objects.requireNonNull(agentRollupId, "agentRollupId");
this.captureTime = captureTime;
}
private ImmutableNeedsRollupKey(ImmutableNeedsRollupKey original, String agentRollupId, long captureTime) {
this.agentRollupId = agentRollupId;
this.captureTime = captureTime;
}
/**
* @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;
}
/**
* Copy the current immutable object by setting a value for the {@link GaugeValueDaoImpl.NeedsRollupKey#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 ImmutableNeedsRollupKey withAgentRollupId(String value) {
String newValue = Objects.requireNonNull(value, "agentRollupId");
if (this.agentRollupId.equals(newValue)) return this;
return new ImmutableNeedsRollupKey(this, newValue, this.captureTime);
}
/**
* Copy the current immutable object by setting a value for the {@link GaugeValueDaoImpl.NeedsRollupKey#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 ImmutableNeedsRollupKey withCaptureTime(long value) {
if (this.captureTime == value) return this;
return new ImmutableNeedsRollupKey(this, this.agentRollupId, value);
}
/**
* This instance is equal to all instances of {@code ImmutableNeedsRollupKey} 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 ImmutableNeedsRollupKey
&& equalTo((ImmutableNeedsRollupKey) another);
}
private boolean equalTo(ImmutableNeedsRollupKey another) {
return agentRollupId.equals(another.agentRollupId)
&& captureTime == another.captureTime;
}
/**
* Computes a hash code from attributes: {@code agentRollupId}, {@code captureTime}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + agentRollupId.hashCode();
h += (h << 5) + Longs.hashCode(captureTime);
return h;
}
/**
* Prints the immutable value {@code NeedsRollupKey} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("NeedsRollupKey")
.omitNullValues()
.add("agentRollupId", agentRollupId)
.add("captureTime", captureTime)
.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 = "GaugeValueDaoImpl.NeedsRollupKey", generator = "Immutables")
@Deprecated
@SuppressWarnings("Immutable")
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements GaugeValueDaoImpl.NeedsRollupKey {
@Nullable String agentRollupId;
long captureTime;
boolean captureTimeIsSet;
@JsonProperty("agentRollupId")
public void setAgentRollupId(String agentRollupId) {
this.agentRollupId = agentRollupId;
}
@JsonProperty("captureTime")
public void setCaptureTime(long captureTime) {
this.captureTime = captureTime;
this.captureTimeIsSet = true;
}
@Override
public String agentRollupId() { throw new UnsupportedOperationException(); }
@Override
public long captureTime() { 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 ImmutableNeedsRollupKey fromJson(Json json) {
ImmutableNeedsRollupKey.Builder builder = ImmutableNeedsRollupKey.builder();
if (json.agentRollupId != null) {
builder.agentRollupId(json.agentRollupId);
}
if (json.captureTimeIsSet) {
builder.captureTime(json.captureTime);
}
return builder.build();
}
/**
* Construct a new immutable {@code NeedsRollupKey} instance.
* @param agentRollupId The value for the {@code agentRollupId} attribute
* @param captureTime The value for the {@code captureTime} attribute
* @return An immutable NeedsRollupKey instance
*/
public static ImmutableNeedsRollupKey of(String agentRollupId, long captureTime) {
return new ImmutableNeedsRollupKey(agentRollupId, captureTime);
}
/**
* Creates an immutable copy of a {@link GaugeValueDaoImpl.NeedsRollupKey} 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 NeedsRollupKey instance
*/
public static ImmutableNeedsRollupKey copyOf(GaugeValueDaoImpl.NeedsRollupKey instance) {
if (instance instanceof ImmutableNeedsRollupKey) {
return (ImmutableNeedsRollupKey) instance;
}
return ImmutableNeedsRollupKey.builder()
.copyFrom(instance)
.build();
}
/**
* The serialized form captures the structural content of the value object,
* providing the ability to reconstruct values with the capability to migrate
* data. Uses optional, nullable, and provides flexible handling of
* collection attributes.
*/
@Generated(from = "GaugeValueDaoImpl.NeedsRollupKey", generator = "Immutables")
private static class SerialForm implements Serializable {
private static final long serialVersionUID = 0L;
private final String[] names;
private final Object[] values;
SerialForm(ImmutableNeedsRollupKey instance) {
List names = new ArrayList<>(2);
List