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

org.glowroot.ui.ImmutableAlertConfigDto 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.Optional;
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.Doubles;
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 AlertConfigJsonService.AlertConfigDto}.
 * 

* Use builder to create immutable instances: * {@code ImmutableAlertConfigDto.builder()}. */ @SuppressWarnings("all") @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "AlertConfigJsonService.AlertConfigDto"}) @Immutable final class ImmutableAlertConfigDto extends AlertConfigJsonService.AlertConfigDto { private final Optional serverId; private final String transactionType; private final double percentile; private final int timePeriodMinutes; private final int thresholdMillis; private final int minTransactionCount; private final ImmutableList emailAddresses; private final Optional version; private ImmutableAlertConfigDto( Optional serverId, String transactionType, double percentile, int timePeriodMinutes, int thresholdMillis, int minTransactionCount, ImmutableList emailAddresses, Optional version) { this.serverId = serverId; this.transactionType = transactionType; this.percentile = percentile; this.timePeriodMinutes = timePeriodMinutes; this.thresholdMillis = thresholdMillis; this.minTransactionCount = minTransactionCount; this.emailAddresses = emailAddresses; this.version = version; } /** * @return value of {@code serverId} attribute */ @JsonProperty @Override Optional serverId() { return serverId; } /** * @return value of {@code transactionType} attribute */ @JsonProperty @Override String transactionType() { return transactionType; } /** * @return value of {@code percentile} attribute */ @JsonProperty @Override double percentile() { return percentile; } /** * @return value of {@code timePeriodMinutes} attribute */ @JsonProperty @Override int timePeriodMinutes() { return timePeriodMinutes; } /** * @return value of {@code thresholdMillis} attribute */ @JsonProperty @Override int thresholdMillis() { return thresholdMillis; } /** * @return value of {@code minTransactionCount} attribute */ @JsonProperty @Override int minTransactionCount() { return minTransactionCount; } /** * @return value of {@code emailAddresses} attribute */ @JsonProperty @Override ImmutableList emailAddresses() { return emailAddresses; } /** * @return value of {@code version} attribute */ @JsonProperty @Override Optional version() { return version; } /** * Copy current immutable object by setting present value for optional {@link AlertConfigJsonService.AlertConfigDto#serverId() serverId}. * @param value value for serverId * @return modified copy of {@code this} object */ public final ImmutableAlertConfigDto withServerId(String value) { Optional newValue = Optional.of(value); return new ImmutableAlertConfigDto( newValue, this.transactionType, this.percentile, this.timePeriodMinutes, this.thresholdMillis, this.minTransactionCount, this.emailAddresses, this.version); } /** * Copy current immutable object by setting optional value for {@link AlertConfigJsonService.AlertConfigDto#serverId() serverId}. * Shallow reference equality check on optional value is used to prevent copying of the same value by returning {@code this}. * @param optional value for serverId * @return modified copy of {@code this} object */ public final ImmutableAlertConfigDto withServerId(Optional optional) { if (this.serverId == optional) return this; Optional newValue = Preconditions.checkNotNull(optional); return new ImmutableAlertConfigDto( newValue, this.transactionType, this.percentile, this.timePeriodMinutes, this.thresholdMillis, this.minTransactionCount, this.emailAddresses, this.version); } /** * Copy current immutable object by setting value for {@link AlertConfigJsonService.AlertConfigDto#transactionType() transactionType}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for transactionType * @return modified copy of the {@code this} object */ public final ImmutableAlertConfigDto withTransactionType(String value) { if (this.transactionType == value) return this; String newValue = Preconditions.checkNotNull(value); return new ImmutableAlertConfigDto( this.serverId, newValue, this.percentile, this.timePeriodMinutes, this.thresholdMillis, this.minTransactionCount, this.emailAddresses, this.version); } /** * Copy current immutable object by setting value for {@link AlertConfigJsonService.AlertConfigDto#percentile() percentile}. * @param value new value for percentile * @return modified copy of the {@code this} object */ public final ImmutableAlertConfigDto withPercentile(double value) { double newValue = value; return new ImmutableAlertConfigDto( this.serverId, this.transactionType, newValue, this.timePeriodMinutes, this.thresholdMillis, this.minTransactionCount, this.emailAddresses, this.version); } /** * Copy current immutable object by setting value for {@link AlertConfigJsonService.AlertConfigDto#timePeriodMinutes() timePeriodMinutes}. * Value equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for timePeriodMinutes * @return modified copy of the {@code this} object */ public final ImmutableAlertConfigDto withTimePeriodMinutes(int value) { if (this.timePeriodMinutes == value) return this; int newValue = value; return new ImmutableAlertConfigDto( this.serverId, this.transactionType, this.percentile, newValue, this.thresholdMillis, this.minTransactionCount, this.emailAddresses, this.version); } /** * Copy current immutable object by setting value for {@link AlertConfigJsonService.AlertConfigDto#thresholdMillis() thresholdMillis}. * Value equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for thresholdMillis * @return modified copy of the {@code this} object */ public final ImmutableAlertConfigDto withThresholdMillis(int value) { if (this.thresholdMillis == value) return this; int newValue = value; return new ImmutableAlertConfigDto( this.serverId, this.transactionType, this.percentile, this.timePeriodMinutes, newValue, this.minTransactionCount, this.emailAddresses, this.version); } /** * Copy current immutable object by setting value for {@link AlertConfigJsonService.AlertConfigDto#minTransactionCount() minTransactionCount}. * Value equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for minTransactionCount * @return modified copy of the {@code this} object */ public final ImmutableAlertConfigDto withMinTransactionCount(int value) { if (this.minTransactionCount == value) return this; int newValue = value; return new ImmutableAlertConfigDto( this.serverId, this.transactionType, this.percentile, this.timePeriodMinutes, this.thresholdMillis, newValue, this.emailAddresses, this.version); } /** * Copy current immutable object with elements that replace content of {@link AlertConfigJsonService.AlertConfigDto#emailAddresses() emailAddresses}. * @param elements elements to set * @return modified copy of {@code this} object */ public final ImmutableAlertConfigDto withEmailAddresses(String... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableAlertConfigDto( this.serverId, this.transactionType, this.percentile, this.timePeriodMinutes, this.thresholdMillis, this.minTransactionCount, newValue, this.version); } /** * Copy current immutable object with elements that replace content of {@link AlertConfigJsonService.AlertConfigDto#emailAddresses() emailAddresses}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements iterable of emailAddresses elements to set * @return modified copy of {@code this} object */ public final ImmutableAlertConfigDto withEmailAddresses(Iterable elements) { if (this.emailAddresses == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableAlertConfigDto( this.serverId, this.transactionType, this.percentile, this.timePeriodMinutes, this.thresholdMillis, this.minTransactionCount, newValue, this.version); } /** * Copy current immutable object by setting present value for optional {@link AlertConfigJsonService.AlertConfigDto#version() version}. * @param value value for version * @return modified copy of {@code this} object */ public final ImmutableAlertConfigDto withVersion(String value) { Optional newValue = Optional.of(value); return new ImmutableAlertConfigDto( this.serverId, this.transactionType, this.percentile, this.timePeriodMinutes, this.thresholdMillis, this.minTransactionCount, this.emailAddresses, newValue); } /** * Copy current immutable object by setting optional value for {@link AlertConfigJsonService.AlertConfigDto#version() version}. * Shallow reference equality check on optional value is used to prevent copying of the same value by returning {@code this}. * @param optional value for version * @return modified copy of {@code this} object */ public final ImmutableAlertConfigDto withVersion(Optional optional) { if (this.version == optional) return this; Optional newValue = Preconditions.checkNotNull(optional); return new ImmutableAlertConfigDto( this.serverId, this.transactionType, this.percentile, this.timePeriodMinutes, this.thresholdMillis, this.minTransactionCount, this.emailAddresses, newValue); } /** * This instance is equal to instances of {@code ImmutableAlertConfigDto} 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 ImmutableAlertConfigDto && equalTo((ImmutableAlertConfigDto) another); } private boolean equalTo(ImmutableAlertConfigDto another) { return serverId.equals(another.serverId) && transactionType.equals(another.transactionType) && Double.doubleToLongBits(percentile) == Double.doubleToLongBits(another.percentile) && timePeriodMinutes == another.timePeriodMinutes && thresholdMillis == another.thresholdMillis && minTransactionCount == another.minTransactionCount && emailAddresses.equals(another.emailAddresses) && version.equals(another.version); } /** * Computes hash code from attributes: {@code serverId}, {@code transactionType}, {@code percentile}, {@code timePeriodMinutes}, {@code thresholdMillis}, {@code minTransactionCount}, {@code emailAddresses}, {@code version}. * @return hashCode value */ @Override public int hashCode() { int h = 31; h = h * 17 + serverId.hashCode(); h = h * 17 + transactionType.hashCode(); h = h * 17 + Doubles.hashCode(percentile); h = h * 17 + timePeriodMinutes; h = h * 17 + thresholdMillis; h = h * 17 + minTransactionCount; h = h * 17 + emailAddresses.hashCode(); h = h * 17 + version.hashCode(); return h; } /** * Prints immutable value {@code AlertConfigDto...} with attribute values, * excluding any non-generated and auxiliary attributes. * @return string representation of value */ @Override public String toString() { return MoreObjects.toStringHelper("AlertConfigDto") .add("serverId", serverId) .add("transactionType", transactionType) .add("percentile", percentile) .add("timePeriodMinutes", timePeriodMinutes) .add("thresholdMillis", thresholdMillis) .add("minTransactionCount", minTransactionCount) .add("emailAddresses", emailAddresses) .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 Optional serverId; @JsonProperty @Nullable String transactionType; @JsonProperty @Nullable java.lang.Double percentile; @JsonProperty @Nullable Integer timePeriodMinutes; @JsonProperty @Nullable Integer thresholdMillis; @JsonProperty @Nullable Integer minTransactionCount; @JsonProperty @Nullable ImmutableList emailAddresses; @JsonProperty @Nullable Optional 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 ImmutableAlertConfigDto fromJson(Json json) { ImmutableAlertConfigDto.Builder builder = ImmutableAlertConfigDto.builder(); if (json.serverId != null) { builder.serverId(json.serverId); } if (json.transactionType != null) { builder.transactionType(json.transactionType); } if (json.percentile != null) { builder.percentile(json.percentile); } if (json.timePeriodMinutes != null) { builder.timePeriodMinutes(json.timePeriodMinutes); } if (json.thresholdMillis != null) { builder.thresholdMillis(json.thresholdMillis); } if (json.minTransactionCount != null) { builder.minTransactionCount(json.minTransactionCount); } if (json.emailAddresses != null) { builder.addAllEmailAddresses(json.emailAddresses); } if (json.version != null) { builder.version(json.version); } return builder.build(); } /** * Creates immutable copy of {@link AlertConfigJsonService.AlertConfigDto}. * 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 AlertConfigDto instance */ static ImmutableAlertConfigDto copyOf(AlertConfigJsonService.AlertConfigDto instance) { if (instance instanceof ImmutableAlertConfigDto) { return (ImmutableAlertConfigDto) instance; } return ImmutableAlertConfigDto.builder() .copyFrom(instance) .build(); } /** * Creates builder for {@link org.glowroot.ui.ImmutableAlertConfigDto ImmutableAlertConfigDto}. * @return new ImmutableAlertConfigDto builder */ static ImmutableAlertConfigDto.Builder builder() { return new ImmutableAlertConfigDto.Builder(); } /** * Builds instances of {@link org.glowroot.ui.ImmutableAlertConfigDto ImmutableAlertConfigDto}. * 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_TRANSACTION_TYPE = 0x1L; private static final long INIT_BIT_PERCENTILE = 0x2L; private static final long INIT_BIT_TIME_PERIOD_MINUTES = 0x4L; private static final long INIT_BIT_THRESHOLD_MILLIS = 0x8L; private static final long INIT_BIT_MIN_TRANSACTION_COUNT = 0x10L; private long initBits = 0x1f; private Optional serverId = Optional.absent(); private @Nullable String transactionType; private double percentile; private int timePeriodMinutes; private int thresholdMillis; private int minTransactionCount; private ImmutableList.Builder emailAddressesBuilder = ImmutableList.builder(); private Optional version = Optional.absent(); private Builder() {} /** * Fill builder with attribute values from provided {@link AlertConfigJsonService.AlertConfigDto} 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(AlertConfigJsonService.AlertConfigDto instance) { Preconditions.checkNotNull(instance); Optional serverIdOptional = instance.serverId(); if (serverIdOptional.isPresent()) { serverId(serverIdOptional); } transactionType(instance.transactionType()); percentile(instance.percentile()); timePeriodMinutes(instance.timePeriodMinutes()); thresholdMillis(instance.thresholdMillis()); minTransactionCount(instance.minTransactionCount()); addAllEmailAddresses(instance.emailAddresses()); Optional versionOptional = instance.version(); if (versionOptional.isPresent()) { version(versionOptional); } return this; } /** * Initializes present value for optional {@link AlertConfigJsonService.AlertConfigDto#serverId() serverId}. * @param serverId value for serverId * @return {@code this} builder for chained invocation */ public final Builder serverId(String serverId) { this.serverId = Optional.of(serverId); return this; } /** * Initializes optional value for {@link AlertConfigJsonService.AlertConfigDto#serverId() serverId}. * @param serverId value for serverId * @return {@code this} builder for chained invocation */ public final Builder serverId(Optional serverId) { this.serverId = Preconditions.checkNotNull(serverId); return this; } /** * Initializes value for {@link AlertConfigJsonService.AlertConfigDto#transactionType() transactionType}. * @param transactionType value for transactionType * @return {@code this} builder for chained invocation */ public final Builder transactionType(String transactionType) { this.transactionType = Preconditions.checkNotNull(transactionType); initBits &= ~INIT_BIT_TRANSACTION_TYPE; return this; } /** * Initializes value for {@link AlertConfigJsonService.AlertConfigDto#percentile() percentile}. * @param percentile value for percentile * @return {@code this} builder for chained invocation */ public final Builder percentile(double percentile) { this.percentile = percentile; initBits &= ~INIT_BIT_PERCENTILE; return this; } /** * Initializes value for {@link AlertConfigJsonService.AlertConfigDto#timePeriodMinutes() timePeriodMinutes}. * @param timePeriodMinutes value for timePeriodMinutes * @return {@code this} builder for chained invocation */ public final Builder timePeriodMinutes(int timePeriodMinutes) { this.timePeriodMinutes = timePeriodMinutes; initBits &= ~INIT_BIT_TIME_PERIOD_MINUTES; return this; } /** * Initializes value for {@link AlertConfigJsonService.AlertConfigDto#thresholdMillis() thresholdMillis}. * @param thresholdMillis value for thresholdMillis * @return {@code this} builder for chained invocation */ public final Builder thresholdMillis(int thresholdMillis) { this.thresholdMillis = thresholdMillis; initBits &= ~INIT_BIT_THRESHOLD_MILLIS; return this; } /** * Initializes value for {@link AlertConfigJsonService.AlertConfigDto#minTransactionCount() minTransactionCount}. * @param minTransactionCount value for minTransactionCount * @return {@code this} builder for chained invocation */ public final Builder minTransactionCount(int minTransactionCount) { this.minTransactionCount = minTransactionCount; initBits &= ~INIT_BIT_MIN_TRANSACTION_COUNT; return this; } /** * Adds one element to {@link AlertConfigJsonService.AlertConfigDto#emailAddresses() emailAddresses} list. * @param element emailAddresses element * @return {@code this} builder for chained invocation */ public final Builder addEmailAddresses(String element) { emailAddressesBuilder.add(element); return this; } /** * Adds elements to {@link AlertConfigJsonService.AlertConfigDto#emailAddresses() emailAddresses} list. * @param elements array of emailAddresses elements * @return {@code this} builder for chained invocation */ public final Builder addEmailAddresses(String... elements) { emailAddressesBuilder.add(elements); return this; } /** * Sets or replaces all elements for {@link AlertConfigJsonService.AlertConfigDto#emailAddresses() emailAddresses} list. * @param elements iterable of emailAddresses elements * @return {@code this} builder for chained invocation */ public final Builder emailAddresses(Iterable elements) { emailAddressesBuilder = ImmutableList.builder(); return addAllEmailAddresses(elements); } /** * Adds elements to {@link AlertConfigJsonService.AlertConfigDto#emailAddresses() emailAddresses} list. * @param elements iterable of emailAddresses elements * @return {@code this} builder for chained invocation */ public final Builder addAllEmailAddresses(Iterable elements) { emailAddressesBuilder.addAll(elements); return this; } /** * Initializes present value for optional {@link AlertConfigJsonService.AlertConfigDto#version() version}. * @param version value for version * @return {@code this} builder for chained invocation */ public final Builder version(String version) { this.version = Optional.of(version); return this; } /** * Initializes optional value for {@link AlertConfigJsonService.AlertConfigDto#version() version}. * @param version value for version * @return {@code this} builder for chained invocation */ public final Builder version(Optional version) { this.version = Preconditions.checkNotNull(version); return this; } /** * Builds new {@link org.glowroot.ui.ImmutableAlertConfigDto ImmutableAlertConfigDto}. * @return immutable instance of AlertConfigDto * @throws exception {@code java.lang.IllegalStateException} if any required attributes are missing */ public ImmutableAlertConfigDto build() throws IllegalStateException { checkRequiredAttributes(); return new ImmutableAlertConfigDto( serverId, transactionType, percentile, timePeriodMinutes, thresholdMillis, minTransactionCount, emailAddressesBuilder.build(), version); } private boolean transactionTypeIsSet() { return (initBits & INIT_BIT_TRANSACTION_TYPE) == 0; } private boolean percentileIsSet() { return (initBits & INIT_BIT_PERCENTILE) == 0; } private boolean timePeriodMinutesIsSet() { return (initBits & INIT_BIT_TIME_PERIOD_MINUTES) == 0; } private boolean thresholdMillisIsSet() { return (initBits & INIT_BIT_THRESHOLD_MILLIS) == 0; } private boolean minTransactionCountIsSet() { return (initBits & INIT_BIT_MIN_TRANSACTION_COUNT) == 0; } private void checkRequiredAttributes() throws IllegalStateException { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } } private String formatRequiredAttributesMessage() { List attributes = Lists.newArrayList(); if (!transactionTypeIsSet()) attributes.add("transactionType"); if (!percentileIsSet()) attributes.add("percentile"); if (!timePeriodMinutesIsSet()) attributes.add("timePeriodMinutes"); if (!thresholdMillisIsSet()) attributes.add("thresholdMillis"); if (!minTransactionCountIsSet()) attributes.add("minTransactionCount"); return "Cannot build AlertConfigDto, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy