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

org.glowroot.ui.ImmutableUserInterfaceConfigResponse 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 org.glowroot.agent.shaded.google.common.primitives.Booleans;
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 ConfigJsonService.UserInterfaceConfigResponse}.
 * 

* Use builder to create immutable instances: * {@code ImmutableUserInterfaceConfigResponse.builder()}. */ @SuppressWarnings("all") @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "ConfigJsonService.UserInterfaceConfigResponse"}) @Immutable final class ImmutableUserInterfaceConfigResponse implements ConfigJsonService.UserInterfaceConfigResponse { private final ConfigJsonService.UserInterfaceConfigDto config; private final int activePort; private final boolean portChangeFailed; private ImmutableUserInterfaceConfigResponse( ConfigJsonService.UserInterfaceConfigDto config, int activePort, boolean portChangeFailed) { this.config = config; this.activePort = activePort; this.portChangeFailed = portChangeFailed; } /** * @return value of {@code config} attribute */ @JsonProperty @Override public ConfigJsonService.UserInterfaceConfigDto config() { return config; } /** * @return value of {@code activePort} attribute */ @JsonProperty @Override public int activePort() { return activePort; } /** * @return value of {@code portChangeFailed} attribute */ @JsonProperty @Override public boolean portChangeFailed() { return portChangeFailed; } /** * Copy current immutable object by setting value for {@link ConfigJsonService.UserInterfaceConfigResponse#config() config}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for config * @return modified copy of the {@code this} object */ public final ImmutableUserInterfaceConfigResponse withConfig(ConfigJsonService.UserInterfaceConfigDto value) { if (this.config == value) return this; ConfigJsonService.UserInterfaceConfigDto newValue = Preconditions.checkNotNull(value); return new ImmutableUserInterfaceConfigResponse(newValue, this.activePort, this.portChangeFailed); } /** * Copy current immutable object by setting value for {@link ConfigJsonService.UserInterfaceConfigResponse#activePort() activePort}. * Value equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for activePort * @return modified copy of the {@code this} object */ public final ImmutableUserInterfaceConfigResponse withActivePort(int value) { if (this.activePort == value) return this; int newValue = value; return new ImmutableUserInterfaceConfigResponse(this.config, newValue, this.portChangeFailed); } /** * Copy current immutable object by setting value for {@link ConfigJsonService.UserInterfaceConfigResponse#portChangeFailed() portChangeFailed}. * Value equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for portChangeFailed * @return modified copy of the {@code this} object */ public final ImmutableUserInterfaceConfigResponse withPortChangeFailed(boolean value) { if (this.portChangeFailed == value) return this; boolean newValue = value; return new ImmutableUserInterfaceConfigResponse(this.config, this.activePort, newValue); } /** * This instance is equal to instances of {@code ImmutableUserInterfaceConfigResponse} 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 ImmutableUserInterfaceConfigResponse && equalTo((ImmutableUserInterfaceConfigResponse) another); } private boolean equalTo(ImmutableUserInterfaceConfigResponse another) { return config.equals(another.config) && activePort == another.activePort && portChangeFailed == another.portChangeFailed; } /** * Computes hash code from attributes: {@code config}, {@code activePort}, {@code portChangeFailed}. * @return hashCode value */ @Override public int hashCode() { int h = 31; h = h * 17 + config.hashCode(); h = h * 17 + activePort; h = h * 17 + Booleans.hashCode(portChangeFailed); return h; } /** * Prints immutable value {@code UserInterfaceConfigResponse...} with attribute values, * excluding any non-generated and auxiliary attributes. * @return string representation of value */ @Override public String toString() { return MoreObjects.toStringHelper("UserInterfaceConfigResponse") .add("config", config) .add("activePort", activePort) .add("portChangeFailed", portChangeFailed) .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 ConfigJsonService.UserInterfaceConfigDto config; @JsonProperty @Nullable Integer activePort; @JsonProperty @Nullable Boolean portChangeFailed; } /** * @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 ImmutableUserInterfaceConfigResponse fromJson(Json json) { ImmutableUserInterfaceConfigResponse.Builder builder = ImmutableUserInterfaceConfigResponse.builder(); if (json.config != null) { builder.config(json.config); } if (json.activePort != null) { builder.activePort(json.activePort); } if (json.portChangeFailed != null) { builder.portChangeFailed(json.portChangeFailed); } return builder.build(); } /** * Creates immutable copy of {@link ConfigJsonService.UserInterfaceConfigResponse}. * 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 UserInterfaceConfigResponse instance */ static ImmutableUserInterfaceConfigResponse copyOf(ConfigJsonService.UserInterfaceConfigResponse instance) { if (instance instanceof ImmutableUserInterfaceConfigResponse) { return (ImmutableUserInterfaceConfigResponse) instance; } return ImmutableUserInterfaceConfigResponse.builder() .copyFrom(instance) .build(); } /** * Creates builder for {@link org.glowroot.ui.ImmutableUserInterfaceConfigResponse ImmutableUserInterfaceConfigResponse}. * @return new ImmutableUserInterfaceConfigResponse builder */ static ImmutableUserInterfaceConfigResponse.Builder builder() { return new ImmutableUserInterfaceConfigResponse.Builder(); } /** * Builds instances of {@link org.glowroot.ui.ImmutableUserInterfaceConfigResponse ImmutableUserInterfaceConfigResponse}. * 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_CONFIG = 0x1L; private static final long INIT_BIT_ACTIVE_PORT = 0x2L; private static final long INIT_BIT_PORT_CHANGE_FAILED = 0x4L; private long initBits = 0x7; private @Nullable ConfigJsonService.UserInterfaceConfigDto config; private int activePort; private boolean portChangeFailed; private Builder() {} /** * Fill builder with attribute values from provided {@link ConfigJsonService.UserInterfaceConfigResponse} 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(ConfigJsonService.UserInterfaceConfigResponse instance) { Preconditions.checkNotNull(instance); config(instance.config()); activePort(instance.activePort()); portChangeFailed(instance.portChangeFailed()); return this; } /** * Initializes value for {@link ConfigJsonService.UserInterfaceConfigResponse#config() config}. * @param config value for config * @return {@code this} builder for chained invocation */ public final Builder config(ConfigJsonService.UserInterfaceConfigDto config) { this.config = Preconditions.checkNotNull(config); initBits &= ~INIT_BIT_CONFIG; return this; } /** * Initializes value for {@link ConfigJsonService.UserInterfaceConfigResponse#activePort() activePort}. * @param activePort value for activePort * @return {@code this} builder for chained invocation */ public final Builder activePort(int activePort) { this.activePort = activePort; initBits &= ~INIT_BIT_ACTIVE_PORT; return this; } /** * Initializes value for {@link ConfigJsonService.UserInterfaceConfigResponse#portChangeFailed() portChangeFailed}. * @param portChangeFailed value for portChangeFailed * @return {@code this} builder for chained invocation */ public final Builder portChangeFailed(boolean portChangeFailed) { this.portChangeFailed = portChangeFailed; initBits &= ~INIT_BIT_PORT_CHANGE_FAILED; return this; } /** * Builds new {@link org.glowroot.ui.ImmutableUserInterfaceConfigResponse ImmutableUserInterfaceConfigResponse}. * @return immutable instance of UserInterfaceConfigResponse * @throws exception {@code java.lang.IllegalStateException} if any required attributes are missing */ public ImmutableUserInterfaceConfigResponse build() throws IllegalStateException { checkRequiredAttributes(); return new ImmutableUserInterfaceConfigResponse(config, activePort, portChangeFailed); } private boolean configIsSet() { return (initBits & INIT_BIT_CONFIG) == 0; } private boolean activePortIsSet() { return (initBits & INIT_BIT_ACTIVE_PORT) == 0; } private boolean portChangeFailedIsSet() { return (initBits & INIT_BIT_PORT_CHANGE_FAILED) == 0; } private void checkRequiredAttributes() throws IllegalStateException { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } } private String formatRequiredAttributesMessage() { List attributes = Lists.newArrayList(); if (!configIsSet()) attributes.add("config"); if (!activePortIsSet()) attributes.add("activePort"); if (!portChangeFailedIsSet()) attributes.add("portChangeFailed"); return "Cannot build UserInterfaceConfigResponse, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy