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

org.glowroot.ui.ImmutableMBeanAttributeMapRequest Maven / Gradle / Ivy

There is a newer version: 0.9.28
Show newest version
package org.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.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 JvmJsonService.MBeanAttributeMapRequest}.
 * 

* Use builder to create immutable instances: * {@code ImmutableMBeanAttributeMapRequest.builder()}. */ @SuppressWarnings("all") @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "JvmJsonService.MBeanAttributeMapRequest"}) @Immutable final class ImmutableMBeanAttributeMapRequest implements JvmJsonService.MBeanAttributeMapRequest { private final String serverId; private final String objectName; private ImmutableMBeanAttributeMapRequest(String serverId, String objectName) { this.serverId = serverId; this.objectName = objectName; } /** * @return value of {@code serverId} attribute */ @JsonProperty @Override public String serverId() { return serverId; } /** * @return value of {@code objectName} attribute */ @JsonProperty @Override public String objectName() { return objectName; } /** * Copy current immutable object by setting value for {@link JvmJsonService.MBeanAttributeMapRequest#serverId() serverId}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for serverId * @return modified copy of the {@code this} object */ public final ImmutableMBeanAttributeMapRequest withServerId(String value) { if (this.serverId == value) return this; String newValue = Preconditions.checkNotNull(value); return new ImmutableMBeanAttributeMapRequest(newValue, this.objectName); } /** * Copy current immutable object by setting value for {@link JvmJsonService.MBeanAttributeMapRequest#objectName() objectName}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for objectName * @return modified copy of the {@code this} object */ public final ImmutableMBeanAttributeMapRequest withObjectName(String value) { if (this.objectName == value) return this; String newValue = Preconditions.checkNotNull(value); return new ImmutableMBeanAttributeMapRequest(this.serverId, newValue); } /** * This instance is equal to instances of {@code ImmutableMBeanAttributeMapRequest} with 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 ImmutableMBeanAttributeMapRequest && equalTo((ImmutableMBeanAttributeMapRequest) another); } private boolean equalTo(ImmutableMBeanAttributeMapRequest another) { return serverId.equals(another.serverId) && objectName.equals(another.objectName); } /** * Computes hash code from attributes: {@code serverId}, {@code objectName}. * @return hashCode value */ @Override public int hashCode() { int h = 31; h = h * 17 + serverId.hashCode(); h = h * 17 + objectName.hashCode(); return h; } /** * Prints immutable value {@code MBeanAttributeMapRequest...} with attribute values, * excluding any non-generated and auxiliary attributes. * @return string representation of value */ @Override public String toString() { return MoreObjects.toStringHelper("MBeanAttributeMapRequest") .add("serverId", serverId) .add("objectName", objectName) .toString(); } /** * Simple representation of this value type suitable Jackson binding * @deprecated Do not use this type directly, it exists only for Jackson-binding infrastructure */ @Deprecated static final class Json { @JsonProperty @Nullable String serverId; @JsonProperty @Nullable String objectName; } /** * @param json JSON-bindable data structure * @return immutable value type * @deprecated Do not use this method directly, it exists only for Jackson-binding infrastructure */ @Deprecated @JsonCreator static ImmutableMBeanAttributeMapRequest fromJson(Json json) { ImmutableMBeanAttributeMapRequest.Builder builder = ImmutableMBeanAttributeMapRequest.builder(); if (json.serverId != null) { builder.serverId(json.serverId); } if (json.objectName != null) { builder.objectName(json.objectName); } return builder.build(); } /** * Creates immutable copy of {@link JvmJsonService.MBeanAttributeMapRequest}. * Uses accessors to get values to initialize immutable instance. * If an instance is already immutable, it is returned as is. * @param instance instance to copy * @return copied immutable MBeanAttributeMapRequest instance */ static ImmutableMBeanAttributeMapRequest copyOf(JvmJsonService.MBeanAttributeMapRequest instance) { if (instance instanceof ImmutableMBeanAttributeMapRequest) { return (ImmutableMBeanAttributeMapRequest) instance; } return ImmutableMBeanAttributeMapRequest.builder() .copyFrom(instance) .build(); } /** * Creates builder for {@link org.glowroot.ui.ImmutableMBeanAttributeMapRequest ImmutableMBeanAttributeMapRequest}. * @return new ImmutableMBeanAttributeMapRequest builder */ static ImmutableMBeanAttributeMapRequest.Builder builder() { return new ImmutableMBeanAttributeMapRequest.Builder(); } /** * Builds instances of {@link org.glowroot.ui.ImmutableMBeanAttributeMapRequest ImmutableMBeanAttributeMapRequest}. * Initialize attributes and then invoke {@link #build()} method to create * immutable instance. *

{@code Builder} is not thread safe and generally should not be stored in field or collection, * but used immediately to create instances. */ @NotThreadSafe static final class Builder { private static final long INIT_BIT_SERVER_ID = 0x1L; private static final long INIT_BIT_OBJECT_NAME = 0x2L; private long initBits = 0x3; private @Nullable String serverId; private @Nullable String objectName; private Builder() {} /** * Fill builder with attribute values from provided {@link JvmJsonService.MBeanAttributeMapRequest} instance. * Regular attribute values will be replaced with ones of an instance. * Instance's absent optional values will not replace present values. * @param instance instance to copy values from * @return {@code this} builder for chained invocation */ public final Builder copyFrom(JvmJsonService.MBeanAttributeMapRequest instance) { Preconditions.checkNotNull(instance); serverId(instance.serverId()); objectName(instance.objectName()); return this; } /** * Initializes value for {@link JvmJsonService.MBeanAttributeMapRequest#serverId() serverId}. * @param serverId value for serverId * @return {@code this} builder for chained invocation */ public final Builder serverId(String serverId) { this.serverId = Preconditions.checkNotNull(serverId); initBits &= ~INIT_BIT_SERVER_ID; return this; } /** * Initializes value for {@link JvmJsonService.MBeanAttributeMapRequest#objectName() objectName}. * @param objectName value for objectName * @return {@code this} builder for chained invocation */ public final Builder objectName(String objectName) { this.objectName = Preconditions.checkNotNull(objectName); initBits &= ~INIT_BIT_OBJECT_NAME; return this; } /** * Builds new {@link org.glowroot.ui.ImmutableMBeanAttributeMapRequest ImmutableMBeanAttributeMapRequest}. * @return immutable instance of MBeanAttributeMapRequest * @throws exception {@code java.lang.IllegalStateException} if any required attributes are missing */ public ImmutableMBeanAttributeMapRequest build() throws IllegalStateException { checkRequiredAttributes(); return new ImmutableMBeanAttributeMapRequest(serverId, objectName); } private boolean serverIdIsSet() { return (initBits & INIT_BIT_SERVER_ID) == 0; } private boolean objectNameIsSet() { return (initBits & INIT_BIT_OBJECT_NAME) == 0; } private void checkRequiredAttributes() throws IllegalStateException { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } } private String formatRequiredAttributesMessage() { List attributes = Lists.newArrayList(); if (!serverIdIsSet()) attributes.add("serverId"); if (!objectNameIsSet()) attributes.add("objectName"); return "Cannot build MBeanAttributeMapRequest, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy