
org.glowroot.ui.ImmutableLayout Maven / Gradle / Ivy
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.ImmutableMap;
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 org.glowroot.agent.shaded.google.common.primitives.Longs;
import java.util.List;
import java.util.Map;
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.ConfigRepository;
import org.glowroot.storage.repo.config.UserInterfaceConfig;
/**
* Immutable implementation of {@link LayoutService.Layout}.
*
* Use builder to create immutable instances:
* {@code ImmutableLayout.builder()}.
*/
@SuppressWarnings("all")
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "LayoutService.Layout"})
@Immutable
final class ImmutableLayout extends LayoutService.Layout {
private final boolean central;
private final String footerMessage;
private final boolean adminPasswordEnabled;
private final boolean readOnlyPasswordEnabled;
private final UserInterfaceConfig.AnonymousAccess anonymousAccess;
private final ImmutableList rollupConfigs;
private final ImmutableList rollupExpirationMillis;
private final long gaugeCollectionIntervalMillis;
private final String defaultTransactionType;
private final ImmutableList defaultPercentiles;
private final ImmutableMap serverRollups;
private final String version;
private ImmutableLayout(
boolean central,
String footerMessage,
boolean adminPasswordEnabled,
boolean readOnlyPasswordEnabled,
UserInterfaceConfig.AnonymousAccess anonymousAccess,
ImmutableList rollupConfigs,
ImmutableList rollupExpirationMillis,
long gaugeCollectionIntervalMillis,
String defaultTransactionType,
ImmutableList defaultPercentiles,
ImmutableMap serverRollups) {
this.central = central;
this.footerMessage = footerMessage;
this.adminPasswordEnabled = adminPasswordEnabled;
this.readOnlyPasswordEnabled = readOnlyPasswordEnabled;
this.anonymousAccess = anonymousAccess;
this.rollupConfigs = rollupConfigs;
this.rollupExpirationMillis = rollupExpirationMillis;
this.gaugeCollectionIntervalMillis = gaugeCollectionIntervalMillis;
this.defaultTransactionType = defaultTransactionType;
this.defaultPercentiles = defaultPercentiles;
this.serverRollups = serverRollups;
this.version = Preconditions.checkNotNull(super.version());
}
/**
* @return value of {@code central} attribute
*/
@JsonProperty
@Override
boolean central() {
return central;
}
/**
* @return value of {@code footerMessage} attribute
*/
@JsonProperty
@Override
String footerMessage() {
return footerMessage;
}
/**
* @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 rollupConfigs} attribute
*/
@JsonProperty
@Override
ImmutableList rollupConfigs() {
return rollupConfigs;
}
/**
* @return value of {@code rollupExpirationMillis} attribute
*/
@JsonProperty
@Override
ImmutableList rollupExpirationMillis() {
return rollupExpirationMillis;
}
/**
* @return value of {@code gaugeCollectionIntervalMillis} attribute
*/
@JsonProperty
@Override
long gaugeCollectionIntervalMillis() {
return gaugeCollectionIntervalMillis;
}
/**
* @return value of {@code defaultTransactionType} attribute
*/
@JsonProperty
@Override
String defaultTransactionType() {
return defaultTransactionType;
}
/**
* @return value of {@code defaultPercentiles} attribute
*/
@JsonProperty
@Override
ImmutableList defaultPercentiles() {
return defaultPercentiles;
}
/**
* @return value of {@code serverRollups} attribute
*/
@JsonProperty
@Override
ImmutableMap serverRollups() {
return serverRollups;
}
/**
* @return computed at construction value of {@code version} attribute
*/
@JsonProperty
@Override
public String version() {
return version;
}
/**
* Copy current immutable object by setting value for {@link LayoutService.Layout#central() central}.
* Value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for central
* @return modified copy of the {@code this} object
*/
public final ImmutableLayout withCentral(boolean value) {
if (this.central == value) return this;
boolean newValue = value;
return new ImmutableLayout(
newValue,
this.footerMessage,
this.adminPasswordEnabled,
this.readOnlyPasswordEnabled,
this.anonymousAccess,
this.rollupConfigs,
this.rollupExpirationMillis,
this.gaugeCollectionIntervalMillis,
this.defaultTransactionType,
this.defaultPercentiles,
this.serverRollups);
}
/**
* Copy current immutable object by setting value for {@link LayoutService.Layout#footerMessage() footerMessage}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for footerMessage
* @return modified copy of the {@code this} object
*/
public final ImmutableLayout withFooterMessage(String value) {
if (this.footerMessage == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableLayout(
this.central,
newValue,
this.adminPasswordEnabled,
this.readOnlyPasswordEnabled,
this.anonymousAccess,
this.rollupConfigs,
this.rollupExpirationMillis,
this.gaugeCollectionIntervalMillis,
this.defaultTransactionType,
this.defaultPercentiles,
this.serverRollups);
}
/**
* Copy current immutable object by setting value for {@link LayoutService.Layout#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 ImmutableLayout withAdminPasswordEnabled(boolean value) {
if (this.adminPasswordEnabled == value) return this;
boolean newValue = value;
return new ImmutableLayout(
this.central,
this.footerMessage,
newValue,
this.readOnlyPasswordEnabled,
this.anonymousAccess,
this.rollupConfigs,
this.rollupExpirationMillis,
this.gaugeCollectionIntervalMillis,
this.defaultTransactionType,
this.defaultPercentiles,
this.serverRollups);
}
/**
* Copy current immutable object by setting value for {@link LayoutService.Layout#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 ImmutableLayout withReadOnlyPasswordEnabled(boolean value) {
if (this.readOnlyPasswordEnabled == value) return this;
boolean newValue = value;
return new ImmutableLayout(
this.central,
this.footerMessage,
this.adminPasswordEnabled,
newValue,
this.anonymousAccess,
this.rollupConfigs,
this.rollupExpirationMillis,
this.gaugeCollectionIntervalMillis,
this.defaultTransactionType,
this.defaultPercentiles,
this.serverRollups);
}
/**
* Copy current immutable object by setting value for {@link LayoutService.Layout#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 ImmutableLayout withAnonymousAccess(UserInterfaceConfig.AnonymousAccess value) {
if (this.anonymousAccess == value) return this;
UserInterfaceConfig.AnonymousAccess newValue = Preconditions.checkNotNull(value);
return new ImmutableLayout(
this.central,
this.footerMessage,
this.adminPasswordEnabled,
this.readOnlyPasswordEnabled,
newValue,
this.rollupConfigs,
this.rollupExpirationMillis,
this.gaugeCollectionIntervalMillis,
this.defaultTransactionType,
this.defaultPercentiles,
this.serverRollups);
}
/**
* Copy current immutable object with elements that replace content of {@link LayoutService.Layout#rollupConfigs() rollupConfigs}.
* @param elements elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableLayout withRollupConfigs(ConfigRepository.RollupConfig... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableLayout(
this.central,
this.footerMessage,
this.adminPasswordEnabled,
this.readOnlyPasswordEnabled,
this.anonymousAccess,
newValue,
this.rollupExpirationMillis,
this.gaugeCollectionIntervalMillis,
this.defaultTransactionType,
this.defaultPercentiles,
this.serverRollups);
}
/**
* Copy current immutable object with elements that replace content of {@link LayoutService.Layout#rollupConfigs() rollupConfigs}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements iterable of rollupConfigs elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableLayout withRollupConfigs(Iterable extends ConfigRepository.RollupConfig> elements) {
if (this.rollupConfigs == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableLayout(
this.central,
this.footerMessage,
this.adminPasswordEnabled,
this.readOnlyPasswordEnabled,
this.anonymousAccess,
newValue,
this.rollupExpirationMillis,
this.gaugeCollectionIntervalMillis,
this.defaultTransactionType,
this.defaultPercentiles,
this.serverRollups);
}
/**
* Copy current immutable object with elements that replace content of {@link LayoutService.Layout#rollupExpirationMillis() rollupExpirationMillis}.
* @param elements elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableLayout withRollupExpirationMillis(long... elements) {
ImmutableList newValue = ImmutableList.copyOf(Longs.asList(elements));
return new ImmutableLayout(
this.central,
this.footerMessage,
this.adminPasswordEnabled,
this.readOnlyPasswordEnabled,
this.anonymousAccess,
this.rollupConfigs,
newValue,
this.gaugeCollectionIntervalMillis,
this.defaultTransactionType,
this.defaultPercentiles,
this.serverRollups);
}
/**
* Copy current immutable object with elements that replace content of {@link LayoutService.Layout#rollupExpirationMillis() rollupExpirationMillis}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements iterable of rollupExpirationMillis elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableLayout withRollupExpirationMillis(Iterable elements) {
if (this.rollupExpirationMillis == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableLayout(
this.central,
this.footerMessage,
this.adminPasswordEnabled,
this.readOnlyPasswordEnabled,
this.anonymousAccess,
this.rollupConfigs,
newValue,
this.gaugeCollectionIntervalMillis,
this.defaultTransactionType,
this.defaultPercentiles,
this.serverRollups);
}
/**
* Copy current immutable object by setting value for {@link LayoutService.Layout#gaugeCollectionIntervalMillis() gaugeCollectionIntervalMillis}.
* Value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for gaugeCollectionIntervalMillis
* @return modified copy of the {@code this} object
*/
public final ImmutableLayout withGaugeCollectionIntervalMillis(long value) {
if (this.gaugeCollectionIntervalMillis == value) return this;
long newValue = value;
return new ImmutableLayout(
this.central,
this.footerMessage,
this.adminPasswordEnabled,
this.readOnlyPasswordEnabled,
this.anonymousAccess,
this.rollupConfigs,
this.rollupExpirationMillis,
newValue,
this.defaultTransactionType,
this.defaultPercentiles,
this.serverRollups);
}
/**
* Copy current immutable object by setting value for {@link LayoutService.Layout#defaultTransactionType() defaultTransactionType}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for defaultTransactionType
* @return modified copy of the {@code this} object
*/
public final ImmutableLayout withDefaultTransactionType(String value) {
if (this.defaultTransactionType == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableLayout(
this.central,
this.footerMessage,
this.adminPasswordEnabled,
this.readOnlyPasswordEnabled,
this.anonymousAccess,
this.rollupConfigs,
this.rollupExpirationMillis,
this.gaugeCollectionIntervalMillis,
newValue,
this.defaultPercentiles,
this.serverRollups);
}
/**
* Copy current immutable object with elements that replace content of {@link LayoutService.Layout#defaultPercentiles() defaultPercentiles}.
* @param elements elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableLayout withDefaultPercentiles(double... elements) {
ImmutableList newValue = ImmutableList.copyOf(Doubles.asList(elements));
return new ImmutableLayout(
this.central,
this.footerMessage,
this.adminPasswordEnabled,
this.readOnlyPasswordEnabled,
this.anonymousAccess,
this.rollupConfigs,
this.rollupExpirationMillis,
this.gaugeCollectionIntervalMillis,
this.defaultTransactionType,
newValue,
this.serverRollups);
}
/**
* Copy current immutable object with elements that replace content of {@link LayoutService.Layout#defaultPercentiles() defaultPercentiles}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements iterable of defaultPercentiles elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableLayout withDefaultPercentiles(Iterable elements) {
if (this.defaultPercentiles == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableLayout(
this.central,
this.footerMessage,
this.adminPasswordEnabled,
this.readOnlyPasswordEnabled,
this.anonymousAccess,
this.rollupConfigs,
this.rollupExpirationMillis,
this.gaugeCollectionIntervalMillis,
this.defaultTransactionType,
newValue,
this.serverRollups);
}
/**
* Copy current immutable object by replacing {@link LayoutService.Layout#serverRollups() serverRollups} map with specified map.
* Nulls are not permitted as keys or values.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param entries to be added to serverRollups map
* @return modified copy of {@code this} object
*/
public final ImmutableLayout withServerRollups(Map entries) {
if (this.serverRollups == entries) return this;
ImmutableMap newValue = ImmutableMap.copyOf(entries);
return new ImmutableLayout(
this.central,
this.footerMessage,
this.adminPasswordEnabled,
this.readOnlyPasswordEnabled,
this.anonymousAccess,
this.rollupConfigs,
this.rollupExpirationMillis,
this.gaugeCollectionIntervalMillis,
this.defaultTransactionType,
this.defaultPercentiles,
newValue);
}
/**
* This instance is equal to instances of {@code ImmutableLayout} 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 ImmutableLayout
&& equalTo((ImmutableLayout) another);
}
private boolean equalTo(ImmutableLayout another) {
return central == another.central
&& footerMessage.equals(another.footerMessage)
&& adminPasswordEnabled == another.adminPasswordEnabled
&& readOnlyPasswordEnabled == another.readOnlyPasswordEnabled
&& anonymousAccess.equals(another.anonymousAccess)
&& rollupConfigs.equals(another.rollupConfigs)
&& rollupExpirationMillis.equals(another.rollupExpirationMillis)
&& gaugeCollectionIntervalMillis == another.gaugeCollectionIntervalMillis
&& defaultTransactionType.equals(another.defaultTransactionType)
&& defaultPercentiles.equals(another.defaultPercentiles)
&& serverRollups.equals(another.serverRollups)
&& version.equals(another.version);
}
/**
* Computes hash code from attributes: {@code central}, {@code footerMessage}, {@code adminPasswordEnabled}, {@code readOnlyPasswordEnabled}, {@code anonymousAccess}, {@code rollupConfigs}, {@code rollupExpirationMillis}, {@code gaugeCollectionIntervalMillis}, {@code defaultTransactionType}, {@code defaultPercentiles}, {@code serverRollups}, {@code version}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 31;
h = h * 17 + Booleans.hashCode(central);
h = h * 17 + footerMessage.hashCode();
h = h * 17 + Booleans.hashCode(adminPasswordEnabled);
h = h * 17 + Booleans.hashCode(readOnlyPasswordEnabled);
h = h * 17 + anonymousAccess.hashCode();
h = h * 17 + rollupConfigs.hashCode();
h = h * 17 + rollupExpirationMillis.hashCode();
h = h * 17 + Longs.hashCode(gaugeCollectionIntervalMillis);
h = h * 17 + defaultTransactionType.hashCode();
h = h * 17 + defaultPercentiles.hashCode();
h = h * 17 + serverRollups.hashCode();
h = h * 17 + version.hashCode();
return h;
}
/**
* Prints immutable value {@code Layout...} with attribute values,
* excluding any non-generated and auxiliary attributes.
* @return string representation of value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("Layout")
.add("central", central)
.add("footerMessage", footerMessage)
.add("adminPasswordEnabled", adminPasswordEnabled)
.add("readOnlyPasswordEnabled", readOnlyPasswordEnabled)
.add("anonymousAccess", anonymousAccess)
.add("rollupConfigs", rollupConfigs)
.add("rollupExpirationMillis", rollupExpirationMillis)
.add("gaugeCollectionIntervalMillis", gaugeCollectionIntervalMillis)
.add("defaultTransactionType", defaultTransactionType)
.add("defaultPercentiles", defaultPercentiles)
.add("serverRollups", serverRollups)
.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 Boolean central;
@JsonProperty
@Nullable String footerMessage;
@JsonProperty
@Nullable Boolean adminPasswordEnabled;
@JsonProperty
@Nullable Boolean readOnlyPasswordEnabled;
@JsonProperty
@Nullable UserInterfaceConfig.AnonymousAccess anonymousAccess;
@JsonProperty
@Nullable ImmutableList rollupConfigs;
@JsonProperty
@Nullable ImmutableList rollupExpirationMillis;
@JsonProperty
@Nullable Long gaugeCollectionIntervalMillis;
@JsonProperty
@Nullable String defaultTransactionType;
@JsonProperty
@Nullable ImmutableList defaultPercentiles;
@JsonProperty
@Nullable ImmutableMap serverRollups;
@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 ImmutableLayout fromJson(Json json) {
ImmutableLayout.Builder builder = ImmutableLayout.builder();
if (json.central != null) {
builder.central(json.central);
}
if (json.footerMessage != null) {
builder.footerMessage(json.footerMessage);
}
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.rollupConfigs != null) {
builder.addAllRollupConfigs(json.rollupConfigs);
}
if (json.rollupExpirationMillis != null) {
builder.addAllRollupExpirationMillis(json.rollupExpirationMillis);
}
if (json.gaugeCollectionIntervalMillis != null) {
builder.gaugeCollectionIntervalMillis(json.gaugeCollectionIntervalMillis);
}
if (json.defaultTransactionType != null) {
builder.defaultTransactionType(json.defaultTransactionType);
}
if (json.defaultPercentiles != null) {
builder.addAllDefaultPercentiles(json.defaultPercentiles);
}
if (json.serverRollups != null) {
builder.putAllServerRollups(json.serverRollups);
}
return builder.build();
}
/**
* Creates immutable copy of {@link LayoutService.Layout}.
* 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 Layout instance
*/
static ImmutableLayout copyOf(LayoutService.Layout instance) {
if (instance instanceof ImmutableLayout) {
return (ImmutableLayout) instance;
}
return ImmutableLayout.builder()
.copyFrom(instance)
.build();
}
/**
* Creates builder for {@link org.glowroot.ui.ImmutableLayout ImmutableLayout}.
* @return new ImmutableLayout builder
*/
static ImmutableLayout.Builder builder() {
return new ImmutableLayout.Builder();
}
/**
* Builds instances of {@link org.glowroot.ui.ImmutableLayout ImmutableLayout}.
* 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_CENTRAL = 0x1L;
private static final long INIT_BIT_FOOTER_MESSAGE = 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_GAUGE_COLLECTION_INTERVAL_MILLIS = 0x20L;
private static final long INIT_BIT_DEFAULT_TRANSACTION_TYPE = 0x40L;
private long initBits = 0x7f;
private boolean central;
private @Nullable String footerMessage;
private boolean adminPasswordEnabled;
private boolean readOnlyPasswordEnabled;
private @Nullable UserInterfaceConfig.AnonymousAccess anonymousAccess;
private ImmutableList.Builder rollupConfigsBuilder = ImmutableList.builder();
private ImmutableList.Builder rollupExpirationMillisBuilder = ImmutableList.builder();
private long gaugeCollectionIntervalMillis;
private @Nullable String defaultTransactionType;
private ImmutableList.Builder defaultPercentilesBuilder = ImmutableList.builder();
private ImmutableMap.Builder serverRollupsBuilder = ImmutableMap.builder();
private Builder() {}
/**
* Fill builder with attribute values from provided {@link LayoutService.Layout} 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(LayoutService.Layout instance) {
Preconditions.checkNotNull(instance);
central(instance.central());
footerMessage(instance.footerMessage());
adminPasswordEnabled(instance.adminPasswordEnabled());
readOnlyPasswordEnabled(instance.readOnlyPasswordEnabled());
anonymousAccess(instance.anonymousAccess());
addAllRollupConfigs(instance.rollupConfigs());
addAllRollupExpirationMillis(instance.rollupExpirationMillis());
gaugeCollectionIntervalMillis(instance.gaugeCollectionIntervalMillis());
defaultTransactionType(instance.defaultTransactionType());
addAllDefaultPercentiles(instance.defaultPercentiles());
putAllServerRollups(instance.serverRollups());
return this;
}
/**
* Initializes value for {@link LayoutService.Layout#central() central}.
* @param central value for central
* @return {@code this} builder for chained invocation
*/
public final Builder central(boolean central) {
this.central = central;
initBits &= ~INIT_BIT_CENTRAL;
return this;
}
/**
* Initializes value for {@link LayoutService.Layout#footerMessage() footerMessage}.
* @param footerMessage value for footerMessage
* @return {@code this} builder for chained invocation
*/
public final Builder footerMessage(String footerMessage) {
this.footerMessage = Preconditions.checkNotNull(footerMessage);
initBits &= ~INIT_BIT_FOOTER_MESSAGE;
return this;
}
/**
* Initializes value for {@link LayoutService.Layout#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 LayoutService.Layout#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 LayoutService.Layout#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;
}
/**
* Adds one element to {@link LayoutService.Layout#rollupConfigs() rollupConfigs} list.
* @param element rollupConfigs element
* @return {@code this} builder for chained invocation
*/
public final Builder addRollupConfigs(ConfigRepository.RollupConfig element) {
rollupConfigsBuilder.add(element);
return this;
}
/**
* Adds elements to {@link LayoutService.Layout#rollupConfigs() rollupConfigs} list.
* @param elements array of rollupConfigs elements
* @return {@code this} builder for chained invocation
*/
public final Builder addRollupConfigs(ConfigRepository.RollupConfig... elements) {
rollupConfigsBuilder.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link LayoutService.Layout#rollupConfigs() rollupConfigs} list.
* @param elements iterable of rollupConfigs elements
* @return {@code this} builder for chained invocation
*/
public final Builder rollupConfigs(Iterable extends ConfigRepository.RollupConfig> elements) {
rollupConfigsBuilder = ImmutableList.builder();
return addAllRollupConfigs(elements);
}
/**
* Adds elements to {@link LayoutService.Layout#rollupConfigs() rollupConfigs} list.
* @param elements iterable of rollupConfigs elements
* @return {@code this} builder for chained invocation
*/
public final Builder addAllRollupConfigs(Iterable extends ConfigRepository.RollupConfig> elements) {
rollupConfigsBuilder.addAll(elements);
return this;
}
/**
* Adds one element to {@link LayoutService.Layout#rollupExpirationMillis() rollupExpirationMillis} list.
* @param element rollupExpirationMillis element
* @return {@code this} builder for chained invocation
*/
public final Builder addRollupExpirationMillis(long element) {
rollupExpirationMillisBuilder.add(element);
return this;
}
/**
* Adds elements to {@link LayoutService.Layout#rollupExpirationMillis() rollupExpirationMillis} list.
* @param elements array of rollupExpirationMillis elements
* @return {@code this} builder for chained invocation
*/
public final Builder addRollupExpirationMillis(long... elements) {
rollupExpirationMillisBuilder.addAll(Longs.asList(elements));
return this;
}
/**
* Sets or replaces all elements for {@link LayoutService.Layout#rollupExpirationMillis() rollupExpirationMillis} list.
* @param elements iterable of rollupExpirationMillis elements
* @return {@code this} builder for chained invocation
*/
public final Builder rollupExpirationMillis(Iterable elements) {
rollupExpirationMillisBuilder = ImmutableList.builder();
return addAllRollupExpirationMillis(elements);
}
/**
* Adds elements to {@link LayoutService.Layout#rollupExpirationMillis() rollupExpirationMillis} list.
* @param elements iterable of rollupExpirationMillis elements
* @return {@code this} builder for chained invocation
*/
public final Builder addAllRollupExpirationMillis(Iterable elements) {
rollupExpirationMillisBuilder.addAll(elements);
return this;
}
/**
* Initializes value for {@link LayoutService.Layout#gaugeCollectionIntervalMillis() gaugeCollectionIntervalMillis}.
* @param gaugeCollectionIntervalMillis value for gaugeCollectionIntervalMillis
* @return {@code this} builder for chained invocation
*/
public final Builder gaugeCollectionIntervalMillis(long gaugeCollectionIntervalMillis) {
this.gaugeCollectionIntervalMillis = gaugeCollectionIntervalMillis;
initBits &= ~INIT_BIT_GAUGE_COLLECTION_INTERVAL_MILLIS;
return this;
}
/**
* Initializes value for {@link LayoutService.Layout#defaultTransactionType() defaultTransactionType}.
* @param defaultTransactionType value for defaultTransactionType
* @return {@code this} builder for chained invocation
*/
public final Builder defaultTransactionType(String defaultTransactionType) {
this.defaultTransactionType = Preconditions.checkNotNull(defaultTransactionType);
initBits &= ~INIT_BIT_DEFAULT_TRANSACTION_TYPE;
return this;
}
/**
* Adds one element to {@link LayoutService.Layout#defaultPercentiles() defaultPercentiles} list.
* @param element defaultPercentiles element
* @return {@code this} builder for chained invocation
*/
public final Builder addDefaultPercentiles(double element) {
defaultPercentilesBuilder.add(element);
return this;
}
/**
* Adds elements to {@link LayoutService.Layout#defaultPercentiles() defaultPercentiles} list.
* @param elements array of defaultPercentiles elements
* @return {@code this} builder for chained invocation
*/
public final Builder addDefaultPercentiles(double... elements) {
defaultPercentilesBuilder.addAll(Doubles.asList(elements));
return this;
}
/**
* Sets or replaces all elements for {@link LayoutService.Layout#defaultPercentiles() defaultPercentiles} list.
* @param elements iterable of defaultPercentiles elements
* @return {@code this} builder for chained invocation
*/
public final Builder defaultPercentiles(Iterable elements) {
defaultPercentilesBuilder = ImmutableList.builder();
return addAllDefaultPercentiles(elements);
}
/**
* Adds elements to {@link LayoutService.Layout#defaultPercentiles() defaultPercentiles} list.
* @param elements iterable of defaultPercentiles elements
* @return {@code this} builder for chained invocation
*/
public final Builder addAllDefaultPercentiles(Iterable elements) {
defaultPercentilesBuilder.addAll(elements);
return this;
}
/**
* Put one entry to {@link LayoutService.Layout#serverRollups() serverRollups} map.
* @param key the key in serverRollups map
* @param value the associated value in serverRollups map
* @return {@code this} builder for chained invocation
*/
public final Builder putServerRollups(String key, LayoutService.ServerRollupLayout value) {
serverRollupsBuilder.put(key, value);
return this;
}
/**
* Put one entry to {@link LayoutService.Layout#serverRollups() serverRollups} map. Nulls are not permitted
* @param entry the key and value entry
* @return {@code this} builder for chained invocation
*/
public final Builder putServerRollups(Map.Entry entry) {
serverRollupsBuilder.put(entry);
return this;
}
/**
* Sets or replaces all mappings from specified map as entries for {@link LayoutService.Layout#serverRollups() serverRollups} map. Nulls are not permitted
* @param entries to be added to serverRollups map
* @return {@code this} builder for chained invocation
*/
public final Builder serverRollups(Map entries) {
serverRollupsBuilder = ImmutableMap.builder();
return putAllServerRollups(entries);
}
/**
* Put all mappings from specified map as entries to {@link LayoutService.Layout#serverRollups() serverRollups} map. Nulls are not permitted
* @param entries to be added to serverRollups map
* @return {@code this} builder for chained invocation
*/
public final Builder putAllServerRollups(Map entries) {
serverRollupsBuilder.putAll(entries);
return this;
}
/**
* Builds new {@link org.glowroot.ui.ImmutableLayout ImmutableLayout}.
* @return immutable instance of Layout
* @throws exception {@code java.lang.IllegalStateException} if any required attributes are missing
*/
public ImmutableLayout build()
throws IllegalStateException {
checkRequiredAttributes();
return new ImmutableLayout(
central,
footerMessage,
adminPasswordEnabled,
readOnlyPasswordEnabled,
anonymousAccess,
rollupConfigsBuilder.build(),
rollupExpirationMillisBuilder.build(),
gaugeCollectionIntervalMillis,
defaultTransactionType,
defaultPercentilesBuilder.build(),
serverRollupsBuilder.build());
}
private boolean centralIsSet() {
return (initBits & INIT_BIT_CENTRAL) == 0;
}
private boolean footerMessageIsSet() {
return (initBits & INIT_BIT_FOOTER_MESSAGE) == 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 gaugeCollectionIntervalMillisIsSet() {
return (initBits & INIT_BIT_GAUGE_COLLECTION_INTERVAL_MILLIS) == 0;
}
private boolean defaultTransactionTypeIsSet() {
return (initBits & INIT_BIT_DEFAULT_TRANSACTION_TYPE) == 0;
}
private void checkRequiredAttributes() throws IllegalStateException {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = Lists.newArrayList();
if (!centralIsSet()) attributes.add("central");
if (!footerMessageIsSet()) attributes.add("footerMessage");
if (!adminPasswordEnabledIsSet()) attributes.add("adminPasswordEnabled");
if (!readOnlyPasswordEnabledIsSet()) attributes.add("readOnlyPasswordEnabled");
if (!anonymousAccessIsSet()) attributes.add("anonymousAccess");
if (!gaugeCollectionIntervalMillisIsSet()) attributes.add("gaugeCollectionIntervalMillis");
if (!defaultTransactionTypeIsSet()) attributes.add("defaultTransactionType");
return "Cannot build Layout, some of required attributes are not set " + attributes;
}
}
}