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

org.glowroot.ui.ImmutableUserInterfaceConfigDto 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.ImmutableList;
import org.glowroot.agent.shaded.google.common.collect.Lists;
import org.glowroot.agent.shaded.google.common.primitives.Booleans;
import org.glowroot.agent.shaded.google.common.primitives.Doubles;
import java.util.ArrayList;
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;
import org.glowroot.storage.repo.config.UserInterfaceConfig;

/**
 * Immutable implementation of {@link ConfigJsonService.UserInterfaceConfigDto}.
 * 

* Use builder to create immutable instances: * {@code ImmutableUserInterfaceConfigDto.builder()}. */ @SuppressWarnings("all") @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "ConfigJsonService.UserInterfaceConfigDto"}) @Immutable final class ImmutableUserInterfaceConfigDto extends ConfigJsonService.UserInterfaceConfigDto { private final String defaultDisplayedTransactionType; private final ImmutableList defaultDisplayedPercentiles; private final int port; private final boolean adminPasswordEnabled; private final boolean readOnlyPasswordEnabled; private final UserInterfaceConfig.AnonymousAccess anonymousAccess; private final String currentAdminPassword; private final String newAdminPassword; private final String newReadOnlyPassword; private final int sessionTimeoutMinutes; private final String version; private ImmutableUserInterfaceConfigDto(ImmutableUserInterfaceConfigDto.Builder builder) { this.defaultDisplayedTransactionType = builder.defaultDisplayedTransactionType; this.defaultDisplayedPercentiles = builder.defaultDisplayedPercentilesBuilder.build(); this.port = builder.port; this.adminPasswordEnabled = builder.adminPasswordEnabled; this.readOnlyPasswordEnabled = builder.readOnlyPasswordEnabled; this.anonymousAccess = builder.anonymousAccess; this.sessionTimeoutMinutes = builder.sessionTimeoutMinutes; this.version = builder.version; if (builder.currentAdminPassword != null) { initShim.currentAdminPassword(builder.currentAdminPassword); } if (builder.newAdminPassword != null) { initShim.newAdminPassword(builder.newAdminPassword); } if (builder.newReadOnlyPassword != null) { initShim.newReadOnlyPassword(builder.newReadOnlyPassword); } this.currentAdminPassword = initShim.currentAdminPassword(); this.newAdminPassword = initShim.newAdminPassword(); this.newReadOnlyPassword = initShim.newReadOnlyPassword(); this.initShim = null; } private static final int STAGE_INITIALIZING = -1; private static final int STAGE_UNINITIALIZED = 0; private static final int STAGE_INITIALIZED = 1; private volatile InitShim initShim = new InitShim(); private final class InitShim { private String currentAdminPassword; private byte currentAdminPasswordStage; String currentAdminPassword() { if (currentAdminPasswordStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (currentAdminPasswordStage == STAGE_UNINITIALIZED) { currentAdminPasswordStage = STAGE_INITIALIZING; this.currentAdminPassword = Preconditions.checkNotNull(ImmutableUserInterfaceConfigDto.super.currentAdminPassword()); currentAdminPasswordStage = STAGE_INITIALIZED; } return currentAdminPassword; } String currentAdminPassword(String value) { this.currentAdminPassword = value; currentAdminPasswordStage = STAGE_INITIALIZED; return value; } private String newAdminPassword; private byte newAdminPasswordStage; String newAdminPassword() { if (newAdminPasswordStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (newAdminPasswordStage == STAGE_UNINITIALIZED) { newAdminPasswordStage = STAGE_INITIALIZING; this.newAdminPassword = Preconditions.checkNotNull(ImmutableUserInterfaceConfigDto.super.newAdminPassword()); newAdminPasswordStage = STAGE_INITIALIZED; } return newAdminPassword; } String newAdminPassword(String value) { this.newAdminPassword = value; newAdminPasswordStage = STAGE_INITIALIZED; return value; } private String newReadOnlyPassword; private byte newReadOnlyPasswordStage; String newReadOnlyPassword() { if (newReadOnlyPasswordStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (newReadOnlyPasswordStage == STAGE_UNINITIALIZED) { newReadOnlyPasswordStage = STAGE_INITIALIZING; this.newReadOnlyPassword = Preconditions.checkNotNull(ImmutableUserInterfaceConfigDto.super.newReadOnlyPassword()); newReadOnlyPasswordStage = STAGE_INITIALIZED; } return newReadOnlyPassword; } String newReadOnlyPassword(String value) { this.newReadOnlyPassword = value; newReadOnlyPasswordStage = STAGE_INITIALIZED; return value; } private String formatInitCycleMessage() { ArrayList attributes = Lists.newArrayList();; if (currentAdminPasswordStage == STAGE_INITIALIZING) attributes.add("currentAdminPassword"); if (newAdminPasswordStage == STAGE_INITIALIZING) attributes.add("newAdminPassword"); if (newReadOnlyPasswordStage == STAGE_INITIALIZING) attributes.add("newReadOnlyPassword"); return "Cannot build UserInterfaceConfigDto, attribute initializers form cycle" + attributes; } } private ImmutableUserInterfaceConfigDto( String defaultDisplayedTransactionType, ImmutableList defaultDisplayedPercentiles, int port, boolean adminPasswordEnabled, boolean readOnlyPasswordEnabled, UserInterfaceConfig.AnonymousAccess anonymousAccess, String currentAdminPassword, String newAdminPassword, String newReadOnlyPassword, int sessionTimeoutMinutes, String version) { this.defaultDisplayedTransactionType = defaultDisplayedTransactionType; this.defaultDisplayedPercentiles = defaultDisplayedPercentiles; this.port = port; this.adminPasswordEnabled = adminPasswordEnabled; this.readOnlyPasswordEnabled = readOnlyPasswordEnabled; this.anonymousAccess = anonymousAccess; this.currentAdminPassword = currentAdminPassword; this.newAdminPassword = newAdminPassword; this.newReadOnlyPassword = newReadOnlyPassword; this.sessionTimeoutMinutes = sessionTimeoutMinutes; this.version = version; this.initShim = null; } /** * @return value of {@code defaultDisplayedTransactionType} attribute */ @JsonProperty @Override String defaultDisplayedTransactionType() { return defaultDisplayedTransactionType; } /** * @return value of {@code defaultDisplayedPercentiles} attribute */ @JsonProperty @Override ImmutableList defaultDisplayedPercentiles() { return defaultDisplayedPercentiles; } /** * @return value of {@code port} attribute */ @JsonProperty @Override int port() { return port; } /** * @return value of {@code adminPasswordEnabled} attribute */ @JsonProperty @Override boolean adminPasswordEnabled() { return adminPasswordEnabled; } /** * @return value of {@code readOnlyPasswordEnabled} attribute */ @JsonProperty @Override boolean readOnlyPasswordEnabled() { return readOnlyPasswordEnabled; } /** * @return value of {@code anonymousAccess} attribute */ @JsonProperty @Override UserInterfaceConfig.AnonymousAccess anonymousAccess() { return anonymousAccess; } /** * @return value of {@code currentAdminPassword} attribute */ @JsonProperty @Override String currentAdminPassword() { return initShim != null ? initShim.currentAdminPassword() : currentAdminPassword; } /** * @return value of {@code newAdminPassword} attribute */ @JsonProperty @Override String newAdminPassword() { return initShim != null ? initShim.newAdminPassword() : newAdminPassword; } /** * @return value of {@code newReadOnlyPassword} attribute */ @JsonProperty @Override String newReadOnlyPassword() { return initShim != null ? initShim.newReadOnlyPassword() : newReadOnlyPassword; } /** * @return value of {@code sessionTimeoutMinutes} attribute */ @JsonProperty @Override int sessionTimeoutMinutes() { return sessionTimeoutMinutes; } /** * @return value of {@code version} attribute */ @JsonProperty @Override String version() { return version; } /** * Copy current immutable object by setting value for {@link ConfigJsonService.UserInterfaceConfigDto#defaultDisplayedTransactionType() defaultDisplayedTransactionType}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for defaultDisplayedTransactionType * @return modified copy of the {@code this} object */ public final ImmutableUserInterfaceConfigDto withDefaultDisplayedTransactionType(String value) { if (this.defaultDisplayedTransactionType == value) return this; String newValue = Preconditions.checkNotNull(value); return new ImmutableUserInterfaceConfigDto( newValue, this.defaultDisplayedPercentiles, this.port, this.adminPasswordEnabled, this.readOnlyPasswordEnabled, this.anonymousAccess, this.currentAdminPassword, this.newAdminPassword, this.newReadOnlyPassword, this.sessionTimeoutMinutes, this.version); } /** * Copy current immutable object with elements that replace content of {@link ConfigJsonService.UserInterfaceConfigDto#defaultDisplayedPercentiles() defaultDisplayedPercentiles}. * @param elements elements to set * @return modified copy of {@code this} object */ public final ImmutableUserInterfaceConfigDto withDefaultDisplayedPercentiles(double... elements) { ImmutableList newValue = ImmutableList.copyOf(Doubles.asList(elements)); return new ImmutableUserInterfaceConfigDto( this.defaultDisplayedTransactionType, newValue, this.port, this.adminPasswordEnabled, this.readOnlyPasswordEnabled, this.anonymousAccess, this.currentAdminPassword, this.newAdminPassword, this.newReadOnlyPassword, this.sessionTimeoutMinutes, this.version); } /** * Copy current immutable object with elements that replace content of {@link ConfigJsonService.UserInterfaceConfigDto#defaultDisplayedPercentiles() defaultDisplayedPercentiles}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements iterable of defaultDisplayedPercentiles elements to set * @return modified copy of {@code this} object */ public final ImmutableUserInterfaceConfigDto withDefaultDisplayedPercentiles(Iterable elements) { if (this.defaultDisplayedPercentiles == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableUserInterfaceConfigDto( this.defaultDisplayedTransactionType, newValue, this.port, this.adminPasswordEnabled, this.readOnlyPasswordEnabled, this.anonymousAccess, this.currentAdminPassword, this.newAdminPassword, this.newReadOnlyPassword, this.sessionTimeoutMinutes, this.version); } /** * Copy current immutable object by setting value for {@link ConfigJsonService.UserInterfaceConfigDto#port() port}. * Value equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for port * @return modified copy of the {@code this} object */ public final ImmutableUserInterfaceConfigDto withPort(int value) { if (this.port == value) return this; int newValue = value; return new ImmutableUserInterfaceConfigDto( this.defaultDisplayedTransactionType, this.defaultDisplayedPercentiles, newValue, this.adminPasswordEnabled, this.readOnlyPasswordEnabled, this.anonymousAccess, this.currentAdminPassword, this.newAdminPassword, this.newReadOnlyPassword, this.sessionTimeoutMinutes, this.version); } /** * Copy current immutable object by setting value for {@link ConfigJsonService.UserInterfaceConfigDto#adminPasswordEnabled() adminPasswordEnabled}. * Value equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for adminPasswordEnabled * @return modified copy of the {@code this} object */ public final ImmutableUserInterfaceConfigDto withAdminPasswordEnabled(boolean value) { if (this.adminPasswordEnabled == value) return this; boolean newValue = value; return new ImmutableUserInterfaceConfigDto( this.defaultDisplayedTransactionType, this.defaultDisplayedPercentiles, this.port, newValue, this.readOnlyPasswordEnabled, this.anonymousAccess, this.currentAdminPassword, this.newAdminPassword, this.newReadOnlyPassword, this.sessionTimeoutMinutes, this.version); } /** * Copy current immutable object by setting value for {@link ConfigJsonService.UserInterfaceConfigDto#readOnlyPasswordEnabled() readOnlyPasswordEnabled}. * Value equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for readOnlyPasswordEnabled * @return modified copy of the {@code this} object */ public final ImmutableUserInterfaceConfigDto withReadOnlyPasswordEnabled(boolean value) { if (this.readOnlyPasswordEnabled == value) return this; boolean newValue = value; return new ImmutableUserInterfaceConfigDto( this.defaultDisplayedTransactionType, this.defaultDisplayedPercentiles, this.port, this.adminPasswordEnabled, newValue, this.anonymousAccess, this.currentAdminPassword, this.newAdminPassword, this.newReadOnlyPassword, this.sessionTimeoutMinutes, this.version); } /** * Copy current immutable object by setting value for {@link ConfigJsonService.UserInterfaceConfigDto#anonymousAccess() anonymousAccess}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for anonymousAccess * @return modified copy of the {@code this} object */ public final ImmutableUserInterfaceConfigDto withAnonymousAccess(UserInterfaceConfig.AnonymousAccess value) { if (this.anonymousAccess == value) return this; UserInterfaceConfig.AnonymousAccess newValue = Preconditions.checkNotNull(value); return new ImmutableUserInterfaceConfigDto( this.defaultDisplayedTransactionType, this.defaultDisplayedPercentiles, this.port, this.adminPasswordEnabled, this.readOnlyPasswordEnabled, newValue, this.currentAdminPassword, this.newAdminPassword, this.newReadOnlyPassword, this.sessionTimeoutMinutes, this.version); } /** * Copy current immutable object by setting value for {@link ConfigJsonService.UserInterfaceConfigDto#currentAdminPassword() currentAdminPassword}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for currentAdminPassword * @return modified copy of the {@code this} object */ public final ImmutableUserInterfaceConfigDto withCurrentAdminPassword(String value) { if (this.currentAdminPassword == value) return this; String newValue = Preconditions.checkNotNull(value); return new ImmutableUserInterfaceConfigDto( this.defaultDisplayedTransactionType, this.defaultDisplayedPercentiles, this.port, this.adminPasswordEnabled, this.readOnlyPasswordEnabled, this.anonymousAccess, newValue, this.newAdminPassword, this.newReadOnlyPassword, this.sessionTimeoutMinutes, this.version); } /** * Copy current immutable object by setting value for {@link ConfigJsonService.UserInterfaceConfigDto#newAdminPassword() newAdminPassword}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for newAdminPassword * @return modified copy of the {@code this} object */ public final ImmutableUserInterfaceConfigDto withNewAdminPassword(String value) { if (this.newAdminPassword == value) return this; String newValue = Preconditions.checkNotNull(value); return new ImmutableUserInterfaceConfigDto( this.defaultDisplayedTransactionType, this.defaultDisplayedPercentiles, this.port, this.adminPasswordEnabled, this.readOnlyPasswordEnabled, this.anonymousAccess, this.currentAdminPassword, newValue, this.newReadOnlyPassword, this.sessionTimeoutMinutes, this.version); } /** * Copy current immutable object by setting value for {@link ConfigJsonService.UserInterfaceConfigDto#newReadOnlyPassword() newReadOnlyPassword}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for newReadOnlyPassword * @return modified copy of the {@code this} object */ public final ImmutableUserInterfaceConfigDto withNewReadOnlyPassword(String value) { if (this.newReadOnlyPassword == value) return this; String newValue = Preconditions.checkNotNull(value); return new ImmutableUserInterfaceConfigDto( this.defaultDisplayedTransactionType, this.defaultDisplayedPercentiles, this.port, this.adminPasswordEnabled, this.readOnlyPasswordEnabled, this.anonymousAccess, this.currentAdminPassword, this.newAdminPassword, newValue, this.sessionTimeoutMinutes, this.version); } /** * Copy current immutable object by setting value for {@link ConfigJsonService.UserInterfaceConfigDto#sessionTimeoutMinutes() sessionTimeoutMinutes}. * Value equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for sessionTimeoutMinutes * @return modified copy of the {@code this} object */ public final ImmutableUserInterfaceConfigDto withSessionTimeoutMinutes(int value) { if (this.sessionTimeoutMinutes == value) return this; int newValue = value; return new ImmutableUserInterfaceConfigDto( this.defaultDisplayedTransactionType, this.defaultDisplayedPercentiles, this.port, this.adminPasswordEnabled, this.readOnlyPasswordEnabled, this.anonymousAccess, this.currentAdminPassword, this.newAdminPassword, this.newReadOnlyPassword, newValue, this.version); } /** * Copy current immutable object by setting value for {@link ConfigJsonService.UserInterfaceConfigDto#version() version}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for version * @return modified copy of the {@code this} object */ public final ImmutableUserInterfaceConfigDto withVersion(String value) { if (this.version == value) return this; String newValue = Preconditions.checkNotNull(value); return new ImmutableUserInterfaceConfigDto( this.defaultDisplayedTransactionType, this.defaultDisplayedPercentiles, this.port, this.adminPasswordEnabled, this.readOnlyPasswordEnabled, this.anonymousAccess, this.currentAdminPassword, this.newAdminPassword, this.newReadOnlyPassword, this.sessionTimeoutMinutes, newValue); } /** * This instance is equal to instances of {@code ImmutableUserInterfaceConfigDto} 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 ImmutableUserInterfaceConfigDto && equalTo((ImmutableUserInterfaceConfigDto) another); } private boolean equalTo(ImmutableUserInterfaceConfigDto another) { return defaultDisplayedTransactionType.equals(another.defaultDisplayedTransactionType) && defaultDisplayedPercentiles.equals(another.defaultDisplayedPercentiles) && port == another.port && adminPasswordEnabled == another.adminPasswordEnabled && readOnlyPasswordEnabled == another.readOnlyPasswordEnabled && anonymousAccess.equals(another.anonymousAccess) && currentAdminPassword.equals(another.currentAdminPassword) && newAdminPassword.equals(another.newAdminPassword) && newReadOnlyPassword.equals(another.newReadOnlyPassword) && sessionTimeoutMinutes == another.sessionTimeoutMinutes && version.equals(another.version); } /** * Computes hash code from attributes: {@code defaultDisplayedTransactionType}, {@code defaultDisplayedPercentiles}, {@code port}, {@code adminPasswordEnabled}, {@code readOnlyPasswordEnabled}, {@code anonymousAccess}, {@code currentAdminPassword}, {@code newAdminPassword}, {@code newReadOnlyPassword}, {@code sessionTimeoutMinutes}, {@code version}. * @return hashCode value */ @Override public int hashCode() { int h = 31; h = h * 17 + defaultDisplayedTransactionType.hashCode(); h = h * 17 + defaultDisplayedPercentiles.hashCode(); h = h * 17 + port; h = h * 17 + Booleans.hashCode(adminPasswordEnabled); h = h * 17 + Booleans.hashCode(readOnlyPasswordEnabled); h = h * 17 + anonymousAccess.hashCode(); h = h * 17 + currentAdminPassword.hashCode(); h = h * 17 + newAdminPassword.hashCode(); h = h * 17 + newReadOnlyPassword.hashCode(); h = h * 17 + sessionTimeoutMinutes; h = h * 17 + version.hashCode(); return h; } /** * Prints immutable value {@code UserInterfaceConfigDto...} with attribute values, * excluding any non-generated and auxiliary attributes. * @return string representation of value */ @Override public String toString() { return MoreObjects.toStringHelper("UserInterfaceConfigDto") .add("defaultDisplayedTransactionType", defaultDisplayedTransactionType) .add("defaultDisplayedPercentiles", defaultDisplayedPercentiles) .add("port", port) .add("adminPasswordEnabled", adminPasswordEnabled) .add("readOnlyPasswordEnabled", readOnlyPasswordEnabled) .add("anonymousAccess", anonymousAccess) .add("currentAdminPassword", currentAdminPassword) .add("newAdminPassword", newAdminPassword) .add("newReadOnlyPassword", newReadOnlyPassword) .add("sessionTimeoutMinutes", sessionTimeoutMinutes) .add("version", version) .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 defaultDisplayedTransactionType; @JsonProperty @Nullable ImmutableList defaultDisplayedPercentiles; @JsonProperty @Nullable Integer port; @JsonProperty @Nullable Boolean adminPasswordEnabled; @JsonProperty @Nullable Boolean readOnlyPasswordEnabled; @JsonProperty @Nullable UserInterfaceConfig.AnonymousAccess anonymousAccess; @JsonProperty @Nullable String currentAdminPassword; @JsonProperty @Nullable String newAdminPassword; @JsonProperty @Nullable String newReadOnlyPassword; @JsonProperty @Nullable Integer sessionTimeoutMinutes; @JsonProperty @Nullable String version; } /** * @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 ImmutableUserInterfaceConfigDto fromJson(Json json) { ImmutableUserInterfaceConfigDto.Builder builder = ImmutableUserInterfaceConfigDto.builder(); if (json.defaultDisplayedTransactionType != null) { builder.defaultDisplayedTransactionType(json.defaultDisplayedTransactionType); } if (json.defaultDisplayedPercentiles != null) { builder.addAllDefaultDisplayedPercentiles(json.defaultDisplayedPercentiles); } if (json.port != null) { builder.port(json.port); } if (json.adminPasswordEnabled != null) { builder.adminPasswordEnabled(json.adminPasswordEnabled); } if (json.readOnlyPasswordEnabled != null) { builder.readOnlyPasswordEnabled(json.readOnlyPasswordEnabled); } if (json.anonymousAccess != null) { builder.anonymousAccess(json.anonymousAccess); } if (json.currentAdminPassword != null) { builder.currentAdminPassword(json.currentAdminPassword); } if (json.newAdminPassword != null) { builder.newAdminPassword(json.newAdminPassword); } if (json.newReadOnlyPassword != null) { builder.newReadOnlyPassword(json.newReadOnlyPassword); } if (json.sessionTimeoutMinutes != null) { builder.sessionTimeoutMinutes(json.sessionTimeoutMinutes); } if (json.version != null) { builder.version(json.version); } return builder.build(); } /** * Creates immutable copy of {@link ConfigJsonService.UserInterfaceConfigDto}. * 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 UserInterfaceConfigDto instance */ static ImmutableUserInterfaceConfigDto copyOf(ConfigJsonService.UserInterfaceConfigDto instance) { if (instance instanceof ImmutableUserInterfaceConfigDto) { return (ImmutableUserInterfaceConfigDto) instance; } return ImmutableUserInterfaceConfigDto.builder() .copyFrom(instance) .build(); } /** * Creates builder for {@link org.glowroot.ui.ImmutableUserInterfaceConfigDto ImmutableUserInterfaceConfigDto}. * @return new ImmutableUserInterfaceConfigDto builder */ static ImmutableUserInterfaceConfigDto.Builder builder() { return new ImmutableUserInterfaceConfigDto.Builder(); } /** * Builds instances of {@link org.glowroot.ui.ImmutableUserInterfaceConfigDto ImmutableUserInterfaceConfigDto}. * 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_DEFAULT_DISPLAYED_TRANSACTION_TYPE = 0x1L; private static final long INIT_BIT_PORT = 0x2L; private static final long INIT_BIT_ADMIN_PASSWORD_ENABLED = 0x4L; private static final long INIT_BIT_READ_ONLY_PASSWORD_ENABLED = 0x8L; private static final long INIT_BIT_ANONYMOUS_ACCESS = 0x10L; private static final long INIT_BIT_SESSION_TIMEOUT_MINUTES = 0x20L; private static final long INIT_BIT_VERSION = 0x40L; private long initBits = 0x7f; private @Nullable String defaultDisplayedTransactionType; private ImmutableList.Builder defaultDisplayedPercentilesBuilder = ImmutableList.builder(); private int port; private boolean adminPasswordEnabled; private boolean readOnlyPasswordEnabled; private @Nullable UserInterfaceConfig.AnonymousAccess anonymousAccess; private @Nullable String currentAdminPassword; private @Nullable String newAdminPassword; private @Nullable String newReadOnlyPassword; private int sessionTimeoutMinutes; private @Nullable String version; private Builder() {} /** * Fill builder with attribute values from provided {@link ConfigJsonService.UserInterfaceConfigDto} instance. * Regular attribute values will be replaced with ones of an instance. * Instance's absent optional values will not replace present values. * Collection elements and entries will be added, not replaced. * @param instance instance to copy values from * @return {@code this} builder for chained invocation */ public final Builder copyFrom(ConfigJsonService.UserInterfaceConfigDto instance) { Preconditions.checkNotNull(instance); defaultDisplayedTransactionType(instance.defaultDisplayedTransactionType()); addAllDefaultDisplayedPercentiles(instance.defaultDisplayedPercentiles()); port(instance.port()); adminPasswordEnabled(instance.adminPasswordEnabled()); readOnlyPasswordEnabled(instance.readOnlyPasswordEnabled()); anonymousAccess(instance.anonymousAccess()); currentAdminPassword(instance.currentAdminPassword()); newAdminPassword(instance.newAdminPassword()); newReadOnlyPassword(instance.newReadOnlyPassword()); sessionTimeoutMinutes(instance.sessionTimeoutMinutes()); version(instance.version()); return this; } /** * Initializes value for {@link ConfigJsonService.UserInterfaceConfigDto#defaultDisplayedTransactionType() defaultDisplayedTransactionType}. * @param defaultDisplayedTransactionType value for defaultDisplayedTransactionType * @return {@code this} builder for chained invocation */ public final Builder defaultDisplayedTransactionType(String defaultDisplayedTransactionType) { this.defaultDisplayedTransactionType = Preconditions.checkNotNull(defaultDisplayedTransactionType); initBits &= ~INIT_BIT_DEFAULT_DISPLAYED_TRANSACTION_TYPE; return this; } /** * Adds one element to {@link ConfigJsonService.UserInterfaceConfigDto#defaultDisplayedPercentiles() defaultDisplayedPercentiles} list. * @param element defaultDisplayedPercentiles element * @return {@code this} builder for chained invocation */ public final Builder addDefaultDisplayedPercentiles(double element) { defaultDisplayedPercentilesBuilder.add(element); return this; } /** * Adds elements to {@link ConfigJsonService.UserInterfaceConfigDto#defaultDisplayedPercentiles() defaultDisplayedPercentiles} list. * @param elements array of defaultDisplayedPercentiles elements * @return {@code this} builder for chained invocation */ public final Builder addDefaultDisplayedPercentiles(double... elements) { defaultDisplayedPercentilesBuilder.addAll(Doubles.asList(elements)); return this; } /** * Sets or replaces all elements for {@link ConfigJsonService.UserInterfaceConfigDto#defaultDisplayedPercentiles() defaultDisplayedPercentiles} list. * @param elements iterable of defaultDisplayedPercentiles elements * @return {@code this} builder for chained invocation */ public final Builder defaultDisplayedPercentiles(Iterable elements) { defaultDisplayedPercentilesBuilder = ImmutableList.builder(); return addAllDefaultDisplayedPercentiles(elements); } /** * Adds elements to {@link ConfigJsonService.UserInterfaceConfigDto#defaultDisplayedPercentiles() defaultDisplayedPercentiles} list. * @param elements iterable of defaultDisplayedPercentiles elements * @return {@code this} builder for chained invocation */ public final Builder addAllDefaultDisplayedPercentiles(Iterable elements) { defaultDisplayedPercentilesBuilder.addAll(elements); return this; } /** * Initializes value for {@link ConfigJsonService.UserInterfaceConfigDto#port() port}. * @param port value for port * @return {@code this} builder for chained invocation */ public final Builder port(int port) { this.port = port; initBits &= ~INIT_BIT_PORT; return this; } /** * Initializes value for {@link ConfigJsonService.UserInterfaceConfigDto#adminPasswordEnabled() adminPasswordEnabled}. * @param adminPasswordEnabled value for adminPasswordEnabled * @return {@code this} builder for chained invocation */ public final Builder adminPasswordEnabled(boolean adminPasswordEnabled) { this.adminPasswordEnabled = adminPasswordEnabled; initBits &= ~INIT_BIT_ADMIN_PASSWORD_ENABLED; return this; } /** * Initializes value for {@link ConfigJsonService.UserInterfaceConfigDto#readOnlyPasswordEnabled() readOnlyPasswordEnabled}. * @param readOnlyPasswordEnabled value for readOnlyPasswordEnabled * @return {@code this} builder for chained invocation */ public final Builder readOnlyPasswordEnabled(boolean readOnlyPasswordEnabled) { this.readOnlyPasswordEnabled = readOnlyPasswordEnabled; initBits &= ~INIT_BIT_READ_ONLY_PASSWORD_ENABLED; return this; } /** * Initializes value for {@link ConfigJsonService.UserInterfaceConfigDto#anonymousAccess() anonymousAccess}. * @param anonymousAccess value for anonymousAccess * @return {@code this} builder for chained invocation */ public final Builder anonymousAccess(UserInterfaceConfig.AnonymousAccess anonymousAccess) { this.anonymousAccess = Preconditions.checkNotNull(anonymousAccess); initBits &= ~INIT_BIT_ANONYMOUS_ACCESS; return this; } /** * Initializes value for {@link ConfigJsonService.UserInterfaceConfigDto#currentAdminPassword() currentAdminPassword}. *

If not set, this attribute will have default value returned by initializer of {@link ConfigJsonService.UserInterfaceConfigDto#currentAdminPassword() currentAdminPassword}. * @param currentAdminPassword value for currentAdminPassword * @return {@code this} builder for chained invocation */ public final Builder currentAdminPassword(String currentAdminPassword) { this.currentAdminPassword = Preconditions.checkNotNull(currentAdminPassword); return this; } /** * Initializes value for {@link ConfigJsonService.UserInterfaceConfigDto#newAdminPassword() newAdminPassword}. *

If not set, this attribute will have default value returned by initializer of {@link ConfigJsonService.UserInterfaceConfigDto#newAdminPassword() newAdminPassword}. * @param newAdminPassword value for newAdminPassword * @return {@code this} builder for chained invocation */ public final Builder newAdminPassword(String newAdminPassword) { this.newAdminPassword = Preconditions.checkNotNull(newAdminPassword); return this; } /** * Initializes value for {@link ConfigJsonService.UserInterfaceConfigDto#newReadOnlyPassword() newReadOnlyPassword}. *

If not set, this attribute will have default value returned by initializer of {@link ConfigJsonService.UserInterfaceConfigDto#newReadOnlyPassword() newReadOnlyPassword}. * @param newReadOnlyPassword value for newReadOnlyPassword * @return {@code this} builder for chained invocation */ public final Builder newReadOnlyPassword(String newReadOnlyPassword) { this.newReadOnlyPassword = Preconditions.checkNotNull(newReadOnlyPassword); return this; } /** * Initializes value for {@link ConfigJsonService.UserInterfaceConfigDto#sessionTimeoutMinutes() sessionTimeoutMinutes}. * @param sessionTimeoutMinutes value for sessionTimeoutMinutes * @return {@code this} builder for chained invocation */ public final Builder sessionTimeoutMinutes(int sessionTimeoutMinutes) { this.sessionTimeoutMinutes = sessionTimeoutMinutes; initBits &= ~INIT_BIT_SESSION_TIMEOUT_MINUTES; return this; } /** * Initializes value for {@link ConfigJsonService.UserInterfaceConfigDto#version() version}. * @param version value for version * @return {@code this} builder for chained invocation */ public final Builder version(String version) { this.version = Preconditions.checkNotNull(version); initBits &= ~INIT_BIT_VERSION; return this; } /** * Builds new {@link org.glowroot.ui.ImmutableUserInterfaceConfigDto ImmutableUserInterfaceConfigDto}. * @return immutable instance of UserInterfaceConfigDto * @throws exception {@code java.lang.IllegalStateException} if any required attributes are missing */ public ImmutableUserInterfaceConfigDto build() throws IllegalStateException { checkRequiredAttributes(); return new ImmutableUserInterfaceConfigDto(this); } private boolean defaultDisplayedTransactionTypeIsSet() { return (initBits & INIT_BIT_DEFAULT_DISPLAYED_TRANSACTION_TYPE) == 0; } private boolean portIsSet() { return (initBits & INIT_BIT_PORT) == 0; } private boolean adminPasswordEnabledIsSet() { return (initBits & INIT_BIT_ADMIN_PASSWORD_ENABLED) == 0; } private boolean readOnlyPasswordEnabledIsSet() { return (initBits & INIT_BIT_READ_ONLY_PASSWORD_ENABLED) == 0; } private boolean anonymousAccessIsSet() { return (initBits & INIT_BIT_ANONYMOUS_ACCESS) == 0; } private boolean sessionTimeoutMinutesIsSet() { return (initBits & INIT_BIT_SESSION_TIMEOUT_MINUTES) == 0; } private boolean versionIsSet() { return (initBits & INIT_BIT_VERSION) == 0; } private void checkRequiredAttributes() throws IllegalStateException { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } } private String formatRequiredAttributesMessage() { List attributes = Lists.newArrayList(); if (!defaultDisplayedTransactionTypeIsSet()) attributes.add("defaultDisplayedTransactionType"); if (!portIsSet()) attributes.add("port"); if (!adminPasswordEnabledIsSet()) attributes.add("adminPasswordEnabled"); if (!readOnlyPasswordEnabledIsSet()) attributes.add("readOnlyPasswordEnabled"); if (!anonymousAccessIsSet()) attributes.add("anonymousAccess"); if (!sessionTimeoutMinutesIsSet()) attributes.add("sessionTimeoutMinutes"); if (!versionIsSet()) attributes.add("version"); return "Cannot build UserInterfaceConfigDto, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy