org.glowroot.central.repo.ImmutableV09AgentRollup 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.collect.Lists;
import com.google.common.primitives.Booleans;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.List;
import java.util.Objects;
import javax.annotation.CheckReturnValue;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
/**
* Immutable implementation of {@link SchemaUpgrade.V09AgentRollup}.
*
* Use the builder to create immutable instances:
* {@code ImmutableV09AgentRollup.builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "SchemaUpgrade.V09AgentRollup"})
@Immutable
@CheckReturnValue
final class ImmutableV09AgentRollup implements SchemaUpgrade.V09AgentRollup {
private final boolean agent;
private final boolean hasRollup;
private final String agentRollupId;
private final String v09AgentRollupId;
private final @Nullable String v09ParentAgentRollupId;
private ImmutableV09AgentRollup(
boolean agent,
boolean hasRollup,
String agentRollupId,
String v09AgentRollupId,
@Nullable String v09ParentAgentRollupId) {
this.agent = agent;
this.hasRollup = hasRollup;
this.agentRollupId = agentRollupId;
this.v09AgentRollupId = v09AgentRollupId;
this.v09ParentAgentRollupId = v09ParentAgentRollupId;
}
/**
* @return The value of the {@code agent} attribute
*/
@JsonProperty("agent")
@Override
public boolean agent() {
return agent;
}
/**
* @return The value of the {@code hasRollup} attribute
*/
@JsonProperty("hasRollup")
@Override
public boolean hasRollup() {
return hasRollup;
}
/**
* @return The value of the {@code agentRollupId} attribute
*/
@JsonProperty("agentRollupId")
@Override
public String agentRollupId() {
return agentRollupId;
}
/**
* @return The value of the {@code v09AgentRollupId} attribute
*/
@JsonProperty("v09AgentRollupId")
@Override
public String v09AgentRollupId() {
return v09AgentRollupId;
}
/**
* @return The value of the {@code v09ParentAgentRollupId} attribute
*/
@JsonProperty("v09ParentAgentRollupId")
@Override
public @Nullable String v09ParentAgentRollupId() {
return v09ParentAgentRollupId;
}
/**
* Copy the current immutable object by setting a value for the {@link SchemaUpgrade.V09AgentRollup#agent() agent} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for agent
* @return A modified copy of the {@code this} object
*/
public final ImmutableV09AgentRollup withAgent(boolean value) {
if (this.agent == value) return this;
return new ImmutableV09AgentRollup(value, this.hasRollup, this.agentRollupId, this.v09AgentRollupId, this.v09ParentAgentRollupId);
}
/**
* Copy the current immutable object by setting a value for the {@link SchemaUpgrade.V09AgentRollup#hasRollup() hasRollup} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for hasRollup
* @return A modified copy of the {@code this} object
*/
public final ImmutableV09AgentRollup withHasRollup(boolean value) {
if (this.hasRollup == value) return this;
return new ImmutableV09AgentRollup(this.agent, value, this.agentRollupId, this.v09AgentRollupId, this.v09ParentAgentRollupId);
}
/**
* Copy the current immutable object by setting a value for the {@link SchemaUpgrade.V09AgentRollup#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 ImmutableV09AgentRollup withAgentRollupId(String value) {
if (this.agentRollupId.equals(value)) return this;
String newValue = Objects.requireNonNull(value, "agentRollupId");
return new ImmutableV09AgentRollup(this.agent, this.hasRollup, newValue, this.v09AgentRollupId, this.v09ParentAgentRollupId);
}
/**
* Copy the current immutable object by setting a value for the {@link SchemaUpgrade.V09AgentRollup#v09AgentRollupId() v09AgentRollupId} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for v09AgentRollupId
* @return A modified copy of the {@code this} object
*/
public final ImmutableV09AgentRollup withV09AgentRollupId(String value) {
if (this.v09AgentRollupId.equals(value)) return this;
String newValue = Objects.requireNonNull(value, "v09AgentRollupId");
return new ImmutableV09AgentRollup(this.agent, this.hasRollup, this.agentRollupId, newValue, this.v09ParentAgentRollupId);
}
/**
* Copy the current immutable object by setting a value for the {@link SchemaUpgrade.V09AgentRollup#v09ParentAgentRollupId() v09ParentAgentRollupId} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for v09ParentAgentRollupId (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableV09AgentRollup withV09ParentAgentRollupId(@Nullable String value) {
if (Objects.equals(this.v09ParentAgentRollupId, value)) return this;
return new ImmutableV09AgentRollup(this.agent, this.hasRollup, this.agentRollupId, this.v09AgentRollupId, value);
}
/**
* This instance is equal to all instances of {@code ImmutableV09AgentRollup} 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 ImmutableV09AgentRollup
&& equalTo((ImmutableV09AgentRollup) another);
}
private boolean equalTo(ImmutableV09AgentRollup another) {
return agent == another.agent
&& hasRollup == another.hasRollup
&& agentRollupId.equals(another.agentRollupId)
&& v09AgentRollupId.equals(another.v09AgentRollupId)
&& Objects.equals(v09ParentAgentRollupId, another.v09ParentAgentRollupId);
}
/**
* Computes a hash code from attributes: {@code agent}, {@code hasRollup}, {@code agentRollupId}, {@code v09AgentRollupId}, {@code v09ParentAgentRollupId}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + Booleans.hashCode(agent);
h += (h << 5) + Booleans.hashCode(hasRollup);
h += (h << 5) + agentRollupId.hashCode();
h += (h << 5) + v09AgentRollupId.hashCode();
h += (h << 5) + Objects.hashCode(v09ParentAgentRollupId);
return h;
}
/**
* Prints the immutable value {@code V09AgentRollup} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("V09AgentRollup")
.omitNullValues()
.add("agent", agent)
.add("hasRollup", hasRollup)
.add("agentRollupId", agentRollupId)
.add("v09AgentRollupId", v09AgentRollupId)
.add("v09ParentAgentRollupId", v09ParentAgentRollupId)
.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
*/
@Deprecated
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements SchemaUpgrade.V09AgentRollup {
boolean agent;
boolean agentIsSet;
boolean hasRollup;
boolean hasRollupIsSet;
@Nullable String agentRollupId;
@Nullable String v09AgentRollupId;
@Nullable String v09ParentAgentRollupId;
@JsonProperty("agent")
public void setAgent(boolean agent) {
this.agent = agent;
this.agentIsSet = true;
}
@JsonProperty("hasRollup")
public void setHasRollup(boolean hasRollup) {
this.hasRollup = hasRollup;
this.hasRollupIsSet = true;
}
@JsonProperty("agentRollupId")
public void setAgentRollupId(String agentRollupId) {
this.agentRollupId = agentRollupId;
}
@JsonProperty("v09AgentRollupId")
public void setV09AgentRollupId(String v09AgentRollupId) {
this.v09AgentRollupId = v09AgentRollupId;
}
@JsonProperty("v09ParentAgentRollupId")
public void setV09ParentAgentRollupId(@Nullable String v09ParentAgentRollupId) {
this.v09ParentAgentRollupId = v09ParentAgentRollupId;
}
@Override
public boolean agent() { throw new UnsupportedOperationException(); }
@Override
public boolean hasRollup() { throw new UnsupportedOperationException(); }
@Override
public String agentRollupId() { throw new UnsupportedOperationException(); }
@Override
public String v09AgentRollupId() { throw new UnsupportedOperationException(); }
@Override
public String v09ParentAgentRollupId() { 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 ImmutableV09AgentRollup fromJson(Json json) {
ImmutableV09AgentRollup.Builder builder = ImmutableV09AgentRollup.builder();
if (json.agentIsSet) {
builder.agent(json.agent);
}
if (json.hasRollupIsSet) {
builder.hasRollup(json.hasRollup);
}
if (json.agentRollupId != null) {
builder.agentRollupId(json.agentRollupId);
}
if (json.v09AgentRollupId != null) {
builder.v09AgentRollupId(json.v09AgentRollupId);
}
if (json.v09ParentAgentRollupId != null) {
builder.v09ParentAgentRollupId(json.v09ParentAgentRollupId);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link SchemaUpgrade.V09AgentRollup} 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 V09AgentRollup instance
*/
public static ImmutableV09AgentRollup copyOf(SchemaUpgrade.V09AgentRollup instance) {
if (instance instanceof ImmutableV09AgentRollup) {
return (ImmutableV09AgentRollup) instance;
}
return ImmutableV09AgentRollup.builder()
.copyFrom(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableV09AgentRollup ImmutableV09AgentRollup}.
* @return A new ImmutableV09AgentRollup builder
*/
public static ImmutableV09AgentRollup.Builder builder() {
return new ImmutableV09AgentRollup.Builder();
}
/**
* Builds instances of type {@link ImmutableV09AgentRollup ImmutableV09AgentRollup}.
* 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.
*/
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_AGENT = 0x1L;
private static final long INIT_BIT_HAS_ROLLUP = 0x2L;
private static final long INIT_BIT_AGENT_ROLLUP_ID = 0x4L;
private static final long INIT_BIT_V09_AGENT_ROLLUP_ID = 0x8L;
private long initBits = 0xfL;
private boolean agent;
private boolean hasRollup;
private @Nullable String agentRollupId;
private @Nullable String v09AgentRollupId;
private @Nullable String v09ParentAgentRollupId;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code V09AgentRollup} 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(SchemaUpgrade.V09AgentRollup instance) {
Objects.requireNonNull(instance, "instance");
agent(instance.agent());
hasRollup(instance.hasRollup());
agentRollupId(instance.agentRollupId());
v09AgentRollupId(instance.v09AgentRollupId());
@Nullable String v09ParentAgentRollupIdValue = instance.v09ParentAgentRollupId();
if (v09ParentAgentRollupIdValue != null) {
v09ParentAgentRollupId(v09ParentAgentRollupIdValue);
}
return this;
}
/**
* Initializes the value for the {@link SchemaUpgrade.V09AgentRollup#agent() agent} attribute.
* @param agent The value for agent
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder agent(boolean agent) {
this.agent = agent;
initBits &= ~INIT_BIT_AGENT;
return this;
}
/**
* Initializes the value for the {@link SchemaUpgrade.V09AgentRollup#hasRollup() hasRollup} attribute.
* @param hasRollup The value for hasRollup
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder hasRollup(boolean hasRollup) {
this.hasRollup = hasRollup;
initBits &= ~INIT_BIT_HAS_ROLLUP;
return this;
}
/**
* Initializes the value for the {@link SchemaUpgrade.V09AgentRollup#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 SchemaUpgrade.V09AgentRollup#v09AgentRollupId() v09AgentRollupId} attribute.
* @param v09AgentRollupId The value for v09AgentRollupId
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder v09AgentRollupId(String v09AgentRollupId) {
this.v09AgentRollupId = Objects.requireNonNull(v09AgentRollupId, "v09AgentRollupId");
initBits &= ~INIT_BIT_V09_AGENT_ROLLUP_ID;
return this;
}
/**
* Initializes the value for the {@link SchemaUpgrade.V09AgentRollup#v09ParentAgentRollupId() v09ParentAgentRollupId} attribute.
* @param v09ParentAgentRollupId The value for v09ParentAgentRollupId (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder v09ParentAgentRollupId(@Nullable String v09ParentAgentRollupId) {
this.v09ParentAgentRollupId = v09ParentAgentRollupId;
return this;
}
/**
* Builds a new {@link ImmutableV09AgentRollup ImmutableV09AgentRollup}.
* @return An immutable instance of V09AgentRollup
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableV09AgentRollup build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableV09AgentRollup(agent, hasRollup, agentRollupId, v09AgentRollupId, v09ParentAgentRollupId);
}
private String formatRequiredAttributesMessage() {
List attributes = Lists.newArrayList();
if ((initBits & INIT_BIT_AGENT) != 0) attributes.add("agent");
if ((initBits & INIT_BIT_HAS_ROLLUP) != 0) attributes.add("hasRollup");
if ((initBits & INIT_BIT_AGENT_ROLLUP_ID) != 0) attributes.add("agentRollupId");
if ((initBits & INIT_BIT_V09_AGENT_ROLLUP_ID) != 0) attributes.add("v09AgentRollupId");
return "Cannot build V09AgentRollup, some of required attributes are not set " + attributes;
}
}
}