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

org.glowroot.central.repo.ImmutableTTL Maven / Gradle / Ivy

package org.glowroot.central.repo;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.immutables.value.Generated;

/**
 * Immutable implementation of {@link AggregateDaoImpl.TTL}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableTTL.builder()}. */ @Generated(from = "AggregateDaoImpl.TTL", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue final class ImmutableTTL implements AggregateDaoImpl.TTL { private final int generalTTL; private final int queryTTL; private final int serviceCallTTL; private final int profileTTL; private ImmutableTTL(int generalTTL, int queryTTL, int serviceCallTTL, int profileTTL) { this.generalTTL = generalTTL; this.queryTTL = queryTTL; this.serviceCallTTL = serviceCallTTL; this.profileTTL = profileTTL; } /** * @return The value of the {@code generalTTL} attribute */ @JsonProperty("generalTTL") @Override public int generalTTL() { return generalTTL; } /** * @return The value of the {@code queryTTL} attribute */ @JsonProperty("queryTTL") @Override public int queryTTL() { return queryTTL; } /** * @return The value of the {@code serviceCallTTL} attribute */ @JsonProperty("serviceCallTTL") @Override public int serviceCallTTL() { return serviceCallTTL; } /** * @return The value of the {@code profileTTL} attribute */ @JsonProperty("profileTTL") @Override public int profileTTL() { return profileTTL; } /** * Copy the current immutable object by setting a value for the {@link AggregateDaoImpl.TTL#generalTTL() generalTTL} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for generalTTL * @return A modified copy of the {@code this} object */ public final ImmutableTTL withGeneralTTL(int value) { if (this.generalTTL == value) return this; return new ImmutableTTL(value, this.queryTTL, this.serviceCallTTL, this.profileTTL); } /** * Copy the current immutable object by setting a value for the {@link AggregateDaoImpl.TTL#queryTTL() queryTTL} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for queryTTL * @return A modified copy of the {@code this} object */ public final ImmutableTTL withQueryTTL(int value) { if (this.queryTTL == value) return this; return new ImmutableTTL(this.generalTTL, value, this.serviceCallTTL, this.profileTTL); } /** * Copy the current immutable object by setting a value for the {@link AggregateDaoImpl.TTL#serviceCallTTL() serviceCallTTL} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for serviceCallTTL * @return A modified copy of the {@code this} object */ public final ImmutableTTL withServiceCallTTL(int value) { if (this.serviceCallTTL == value) return this; return new ImmutableTTL(this.generalTTL, this.queryTTL, value, this.profileTTL); } /** * Copy the current immutable object by setting a value for the {@link AggregateDaoImpl.TTL#profileTTL() profileTTL} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for profileTTL * @return A modified copy of the {@code this} object */ public final ImmutableTTL withProfileTTL(int value) { if (this.profileTTL == value) return this; return new ImmutableTTL(this.generalTTL, this.queryTTL, this.serviceCallTTL, value); } /** * This instance is equal to all instances of {@code ImmutableTTL} that have 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 ImmutableTTL && equalTo((ImmutableTTL) another); } private boolean equalTo(ImmutableTTL another) { return generalTTL == another.generalTTL && queryTTL == another.queryTTL && serviceCallTTL == another.serviceCallTTL && profileTTL == another.profileTTL; } /** * Computes a hash code from attributes: {@code generalTTL}, {@code queryTTL}, {@code serviceCallTTL}, {@code profileTTL}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + generalTTL; h += (h << 5) + queryTTL; h += (h << 5) + serviceCallTTL; h += (h << 5) + profileTTL; return h; } /** * Prints the immutable value {@code TTL} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("TTL") .omitNullValues() .add("generalTTL", generalTTL) .add("queryTTL", queryTTL) .add("serviceCallTTL", serviceCallTTL) .add("profileTTL", profileTTL) .toString(); } /** * Utility type used to correctly read immutable object from JSON representation. * @deprecated Do not use this type directly, it exists only for the Jackson-binding infrastructure */ @Generated(from = "AggregateDaoImpl.TTL", generator = "Immutables") @Deprecated @SuppressWarnings("Immutable") @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements AggregateDaoImpl.TTL { int generalTTL; boolean generalTTLIsSet; int queryTTL; boolean queryTTLIsSet; int serviceCallTTL; boolean serviceCallTTLIsSet; int profileTTL; boolean profileTTLIsSet; @JsonProperty("generalTTL") public void setGeneralTTL(int generalTTL) { this.generalTTL = generalTTL; this.generalTTLIsSet = true; } @JsonProperty("queryTTL") public void setQueryTTL(int queryTTL) { this.queryTTL = queryTTL; this.queryTTLIsSet = true; } @JsonProperty("serviceCallTTL") public void setServiceCallTTL(int serviceCallTTL) { this.serviceCallTTL = serviceCallTTL; this.serviceCallTTLIsSet = true; } @JsonProperty("profileTTL") public void setProfileTTL(int profileTTL) { this.profileTTL = profileTTL; this.profileTTLIsSet = true; } @Override public int generalTTL() { throw new UnsupportedOperationException(); } @Override public int queryTTL() { throw new UnsupportedOperationException(); } @Override public int serviceCallTTL() { throw new UnsupportedOperationException(); } @Override public int profileTTL() { throw new UnsupportedOperationException(); } } /** * @param json A JSON-bindable data structure * @return An immutable value type * @deprecated Do not use this method directly, it exists only for the Jackson-binding infrastructure */ @Deprecated @JsonCreator(mode = JsonCreator.Mode.DELEGATING) static ImmutableTTL fromJson(Json json) { ImmutableTTL.Builder builder = ImmutableTTL.builder(); if (json.generalTTLIsSet) { builder.generalTTL(json.generalTTL); } if (json.queryTTLIsSet) { builder.queryTTL(json.queryTTL); } if (json.serviceCallTTLIsSet) { builder.serviceCallTTL(json.serviceCallTTL); } if (json.profileTTLIsSet) { builder.profileTTL(json.profileTTL); } return builder.build(); } /** * Creates an immutable copy of a {@link AggregateDaoImpl.TTL} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable TTL instance */ public static ImmutableTTL copyOf(AggregateDaoImpl.TTL instance) { if (instance instanceof ImmutableTTL) { return (ImmutableTTL) instance; } return ImmutableTTL.builder() .copyFrom(instance) .build(); } /** * Creates a builder for {@link ImmutableTTL ImmutableTTL}. *

   * ImmutableTTL.builder()
   *    .generalTTL(int) // required {@link AggregateDaoImpl.TTL#generalTTL() generalTTL}
   *    .queryTTL(int) // required {@link AggregateDaoImpl.TTL#queryTTL() queryTTL}
   *    .serviceCallTTL(int) // required {@link AggregateDaoImpl.TTL#serviceCallTTL() serviceCallTTL}
   *    .profileTTL(int) // required {@link AggregateDaoImpl.TTL#profileTTL() profileTTL}
   *    .build();
   * 
* @return A new ImmutableTTL builder */ public static ImmutableTTL.Builder builder() { return new ImmutableTTL.Builder(); } /** * Builds instances of type {@link ImmutableTTL ImmutableTTL}. * Initialize attributes and then invoke the {@link #build()} method to create an * immutable instance. *

{@code Builder} is not thread-safe and generally should not be stored in a field or collection, * but instead used immediately to create instances. */ @Generated(from = "AggregateDaoImpl.TTL", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_GENERAL_T_T_L = 0x1L; private static final long INIT_BIT_QUERY_T_T_L = 0x2L; private static final long INIT_BIT_SERVICE_CALL_T_T_L = 0x4L; private static final long INIT_BIT_PROFILE_T_T_L = 0x8L; private long initBits = 0xfL; private int generalTTL; private int queryTTL; private int serviceCallTTL; private int profileTTL; private Builder() { } /** * Fill a builder with attribute values from the provided {@code TTL} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder copyFrom(AggregateDaoImpl.TTL instance) { Objects.requireNonNull(instance, "instance"); generalTTL(instance.generalTTL()); queryTTL(instance.queryTTL()); serviceCallTTL(instance.serviceCallTTL()); profileTTL(instance.profileTTL()); return this; } /** * Initializes the value for the {@link AggregateDaoImpl.TTL#generalTTL() generalTTL} attribute. * @param generalTTL The value for generalTTL * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder generalTTL(int generalTTL) { this.generalTTL = generalTTL; initBits &= ~INIT_BIT_GENERAL_T_T_L; return this; } /** * Initializes the value for the {@link AggregateDaoImpl.TTL#queryTTL() queryTTL} attribute. * @param queryTTL The value for queryTTL * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder queryTTL(int queryTTL) { this.queryTTL = queryTTL; initBits &= ~INIT_BIT_QUERY_T_T_L; return this; } /** * Initializes the value for the {@link AggregateDaoImpl.TTL#serviceCallTTL() serviceCallTTL} attribute. * @param serviceCallTTL The value for serviceCallTTL * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder serviceCallTTL(int serviceCallTTL) { this.serviceCallTTL = serviceCallTTL; initBits &= ~INIT_BIT_SERVICE_CALL_T_T_L; return this; } /** * Initializes the value for the {@link AggregateDaoImpl.TTL#profileTTL() profileTTL} attribute. * @param profileTTL The value for profileTTL * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder profileTTL(int profileTTL) { this.profileTTL = profileTTL; initBits &= ~INIT_BIT_PROFILE_T_T_L; return this; } /** * Builds a new {@link ImmutableTTL ImmutableTTL}. * @return An immutable instance of TTL * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableTTL build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableTTL(generalTTL, queryTTL, serviceCallTTL, profileTTL); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_GENERAL_T_T_L) != 0) attributes.add("generalTTL"); if ((initBits & INIT_BIT_QUERY_T_T_L) != 0) attributes.add("queryTTL"); if ((initBits & INIT_BIT_SERVICE_CALL_T_T_L) != 0) attributes.add("serviceCallTTL"); if ((initBits & INIT_BIT_PROFILE_T_T_L) != 0) attributes.add("profileTTL"); return "Cannot build TTL, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy