All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.glowroot.agent.shaded.glowroot.ui.ImmutableGaugeConfigRequest Maven / Gradle / Ivy

There is a newer version: 0.9.24
Show newest version
package org.glowroot.agent.shaded.glowroot.ui;

import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonCreator;
import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonProperty;
import org.glowroot.agent.shaded.google.common.base.MoreObjects;
import org.glowroot.agent.shaded.google.common.base.Optional;
import org.glowroot.agent.shaded.google.common.base.Preconditions;
import org.glowroot.agent.shaded.google.common.collect.Lists;
import java.util.List;
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 GaugeConfigJsonService.GaugeConfigRequest}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableGaugeConfigRequest.builder()}. */ @SuppressWarnings("all") @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "GaugeConfigJsonService.GaugeConfigRequest"}) @Immutable final class ImmutableGaugeConfigRequest implements GaugeConfigJsonService.GaugeConfigRequest { private final String agentId; private final Optional version; private ImmutableGaugeConfigRequest(String agentId, Optional version) { this.agentId = agentId; this.version = version; } /** * @return The value of the {@code agentId} attribute */ @JsonProperty @Override public String agentId() { return agentId; } /** * @return The value of the {@code version} attribute */ @JsonProperty @Override public Optional version() { return version; } /** * Copy the current immutable object by setting a value for the {@link GaugeConfigJsonService.GaugeConfigRequest#agentId() agentId} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for agentId * @return A modified copy of the {@code this} object */ public final ImmutableGaugeConfigRequest withAgentId(String value) { if (this.agentId.equals(value)) return this; return new ImmutableGaugeConfigRequest(Preconditions.checkNotNull(value, "agentId"), this.version); } /** * Copy the current immutable object by setting a present value for the optional {@link GaugeConfigJsonService.GaugeConfigRequest#version() version} attribute. * @param value The value for version * @return A modified copy of {@code this} object */ public final ImmutableGaugeConfigRequest withVersion(String value) { Optional newValue = Optional.of(value); if (this.version.equals(newValue)) return this; return new ImmutableGaugeConfigRequest(this.agentId, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link GaugeConfigJsonService.GaugeConfigRequest#version() version} attribute. * An equality check is used to prevent copying of the same value by returning {@code this}. * @param optional A value for version * @return A modified copy of {@code this} object */ public final ImmutableGaugeConfigRequest withVersion(Optional optional) { Optional value = Preconditions.checkNotNull(optional, "version"); if (this.version.equals(value)) return this; return new ImmutableGaugeConfigRequest(this.agentId, value); } /** * This instance is equal to all instances of {@code ImmutableGaugeConfigRequest} 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 ImmutableGaugeConfigRequest && equalTo((ImmutableGaugeConfigRequest) another); } private boolean equalTo(ImmutableGaugeConfigRequest another) { return agentId.equals(another.agentId) && version.equals(another.version); } /** * Computes a hash code from attributes: {@code agentId}, {@code version}. * @return hashCode value */ @Override public int hashCode() { int h = 31; h = h * 17 + agentId.hashCode(); h = h * 17 + version.hashCode(); return h; } /** * Prints the immutable value {@code GaugeConfigRequest...} with all non-generated * and non-auxiliary attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("GaugeConfigRequest") .add("agentId", agentId) .add("version", version) .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 static final class Json implements GaugeConfigJsonService.GaugeConfigRequest { @Nullable String agentId; Optional version = Optional.absent(); @JsonProperty public void setAgentId(String agentId) { this.agentId = agentId; } @JsonProperty public void setVersion(Optional version) { this.version = version; } @Override public String agentId() { throw new UnsupportedOperationException(); } @Override public Optional version() { 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 static ImmutableGaugeConfigRequest fromJson(Json json) { ImmutableGaugeConfigRequest.Builder builder = ImmutableGaugeConfigRequest.builder(); if (json.agentId != null) { builder.agentId(json.agentId); } if (json.version != null) { builder.version(json.version); } return builder.build(); } /** * Creates an immutable copy of a {@link GaugeConfigJsonService.GaugeConfigRequest} 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 GaugeConfigRequest instance */ public static ImmutableGaugeConfigRequest copyOf(GaugeConfigJsonService.GaugeConfigRequest instance) { if (instance instanceof ImmutableGaugeConfigRequest) { return (ImmutableGaugeConfigRequest) instance; } return ImmutableGaugeConfigRequest.builder() .copyFrom(instance) .build(); } /** * Creates a builder for {@link ImmutableGaugeConfigRequest ImmutableGaugeConfigRequest}. * @return A new ImmutableGaugeConfigRequest builder */ public static ImmutableGaugeConfigRequest.Builder builder() { return new ImmutableGaugeConfigRequest.Builder(); } /** * Builds instances of type {@link ImmutableGaugeConfigRequest ImmutableGaugeConfigRequest}. * 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 static final class Builder { private static final long INIT_BIT_AGENT_ID = 0x1L; private long initBits = 0x1; private @Nullable String agentId; private Optional version = Optional.absent(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code GaugeConfigRequest} 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 */ public final Builder copyFrom(GaugeConfigJsonService.GaugeConfigRequest instance) { Preconditions.checkNotNull(instance, "instance"); agentId(instance.agentId()); Optional versionOptional = instance.version(); if (versionOptional.isPresent()) { version(versionOptional); } return this; } /** * Initializes the value for the {@link GaugeConfigJsonService.GaugeConfigRequest#agentId() agentId} attribute. * @param agentId The value for agentId * @return {@code this} builder for use in a chained invocation */ public final Builder agentId(String agentId) { this.agentId = Preconditions.checkNotNull(agentId, "agentId"); initBits &= ~INIT_BIT_AGENT_ID; return this; } /** * Initializes the optional value {@link GaugeConfigJsonService.GaugeConfigRequest#version() version} to version. * @param version The value for version * @return {@code this} builder for chained invocation */ public final Builder version(String version) { this.version = Optional.of(version); return this; } /** * Initializes the optional value {@link GaugeConfigJsonService.GaugeConfigRequest#version() version} to version. * @param version The value for version * @return {@code this} builder for use in a chained invocation */ public final Builder version(Optional version) { this.version = Preconditions.checkNotNull(version, "version"); return this; } /** * Builds a new {@link ImmutableGaugeConfigRequest ImmutableGaugeConfigRequest}. * @return An immutable instance of GaugeConfigRequest * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableGaugeConfigRequest build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableGaugeConfigRequest(agentId, version); } private String formatRequiredAttributesMessage() { List attributes = Lists.newArrayList(); if ((initBits & INIT_BIT_AGENT_ID) != 0) attributes.add("agentId"); return "Cannot build GaugeConfigRequest, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy