
org.glowroot.common.config.ImmutableInstrumentationConfig Maven / Gradle / Ivy
package org.glowroot.common.config;
import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonCreator;
import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonIgnore;
import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonInclude;
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.Objects;
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 java.util.ArrayList;
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;
/**
* Immutable implementation of {@link InstrumentationConfig}.
*
* Use builder to create immutable instances:
* {@code ImmutableInstrumentationConfig.builder()}.
*/
@SuppressWarnings("all")
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "InstrumentationConfig"})
@Immutable
public final class ImmutableInstrumentationConfig extends InstrumentationConfig {
private final String className;
private final String declaringClassName;
private final String methodName;
private final ImmutableList methodParameterTypes;
private final String methodReturnType;
private final ImmutableList methodModifiers;
private final InstrumentationConfig.CaptureKind captureKind;
private final String transactionType;
private final String transactionNameTemplate;
private final String transactionUserTemplate;
private final ImmutableMap transactionAttributeTemplates;
private final @Nullable Integer transactionSlowThresholdMillis;
private final String traceEntryMessageTemplate;
private final @Nullable Integer traceEntryStackThresholdMillis;
private final boolean traceEntryCaptureSelfNested;
private final String timerName;
private final String enabledProperty;
private final String traceEntryEnabledProperty;
private final String version;
private final boolean isTimerOrGreater;
private final boolean isTraceEntryOrGreater;
private final boolean isTransaction;
private final ImmutableList validationErrors;
private ImmutableInstrumentationConfig(ImmutableInstrumentationConfig.Builder builder) {
this.className = builder.className;
this.methodName = builder.methodName;
this.methodParameterTypes = builder.methodParameterTypesBuilder.build();
this.methodModifiers = builder.methodModifiersBuilder.build();
this.captureKind = builder.captureKind;
this.transactionAttributeTemplates = builder.transactionAttributeTemplatesBuilder.build();
this.transactionSlowThresholdMillis = builder.transactionSlowThresholdMillis;
this.traceEntryStackThresholdMillis = builder.traceEntryStackThresholdMillis;
if (builder.declaringClassName != null) {
initShim.declaringClassName(builder.declaringClassName);
}
if (builder.methodReturnType != null) {
initShim.methodReturnType(builder.methodReturnType);
}
if (builder.transactionType != null) {
initShim.transactionType(builder.transactionType);
}
if (builder.transactionNameTemplate != null) {
initShim.transactionNameTemplate(builder.transactionNameTemplate);
}
if (builder.transactionUserTemplate != null) {
initShim.transactionUserTemplate(builder.transactionUserTemplate);
}
if (builder.traceEntryMessageTemplate != null) {
initShim.traceEntryMessageTemplate(builder.traceEntryMessageTemplate);
}
if (builder.traceEntryCaptureSelfNestedIsSet()) {
initShim.traceEntryCaptureSelfNested(builder.traceEntryCaptureSelfNested);
}
if (builder.timerName != null) {
initShim.timerName(builder.timerName);
}
if (builder.enabledProperty != null) {
initShim.enabledProperty(builder.enabledProperty);
}
if (builder.traceEntryEnabledProperty != null) {
initShim.traceEntryEnabledProperty(builder.traceEntryEnabledProperty);
}
this.declaringClassName = initShim.declaringClassName();
this.methodReturnType = initShim.methodReturnType();
this.transactionType = initShim.transactionType();
this.transactionNameTemplate = initShim.transactionNameTemplate();
this.transactionUserTemplate = initShim.transactionUserTemplate();
this.traceEntryMessageTemplate = initShim.traceEntryMessageTemplate();
this.traceEntryCaptureSelfNested = initShim.traceEntryCaptureSelfNested();
this.timerName = initShim.timerName();
this.enabledProperty = initShim.enabledProperty();
this.traceEntryEnabledProperty = initShim.traceEntryEnabledProperty();
this.version = Preconditions.checkNotNull(super.version());
this.isTimerOrGreater = super.isTimerOrGreater();
this.isTraceEntryOrGreater = super.isTraceEntryOrGreater();
this.isTransaction = super.isTransaction();
this.validationErrors = Preconditions.checkNotNull(super.validationErrors());
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 declaringClassName;
private byte declaringClassNameStage;
String declaringClassName() {
if (declaringClassNameStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (declaringClassNameStage == STAGE_UNINITIALIZED) {
declaringClassNameStage = STAGE_INITIALIZING;
this.declaringClassName = Preconditions.checkNotNull(ImmutableInstrumentationConfig.super.declaringClassName());
declaringClassNameStage = STAGE_INITIALIZED;
}
return declaringClassName;
}
String declaringClassName(String value) {
this.declaringClassName = value;
declaringClassNameStage = STAGE_INITIALIZED;
return value;
}
private String methodReturnType;
private byte methodReturnTypeStage;
String methodReturnType() {
if (methodReturnTypeStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (methodReturnTypeStage == STAGE_UNINITIALIZED) {
methodReturnTypeStage = STAGE_INITIALIZING;
this.methodReturnType = Preconditions.checkNotNull(ImmutableInstrumentationConfig.super.methodReturnType());
methodReturnTypeStage = STAGE_INITIALIZED;
}
return methodReturnType;
}
String methodReturnType(String value) {
this.methodReturnType = value;
methodReturnTypeStage = STAGE_INITIALIZED;
return value;
}
private String transactionType;
private byte transactionTypeStage;
String transactionType() {
if (transactionTypeStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (transactionTypeStage == STAGE_UNINITIALIZED) {
transactionTypeStage = STAGE_INITIALIZING;
this.transactionType = Preconditions.checkNotNull(ImmutableInstrumentationConfig.super.transactionType());
transactionTypeStage = STAGE_INITIALIZED;
}
return transactionType;
}
String transactionType(String value) {
this.transactionType = value;
transactionTypeStage = STAGE_INITIALIZED;
return value;
}
private String transactionNameTemplate;
private byte transactionNameTemplateStage;
String transactionNameTemplate() {
if (transactionNameTemplateStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (transactionNameTemplateStage == STAGE_UNINITIALIZED) {
transactionNameTemplateStage = STAGE_INITIALIZING;
this.transactionNameTemplate = Preconditions.checkNotNull(ImmutableInstrumentationConfig.super.transactionNameTemplate());
transactionNameTemplateStage = STAGE_INITIALIZED;
}
return transactionNameTemplate;
}
String transactionNameTemplate(String value) {
this.transactionNameTemplate = value;
transactionNameTemplateStage = STAGE_INITIALIZED;
return value;
}
private String transactionUserTemplate;
private byte transactionUserTemplateStage;
String transactionUserTemplate() {
if (transactionUserTemplateStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (transactionUserTemplateStage == STAGE_UNINITIALIZED) {
transactionUserTemplateStage = STAGE_INITIALIZING;
this.transactionUserTemplate = Preconditions.checkNotNull(ImmutableInstrumentationConfig.super.transactionUserTemplate());
transactionUserTemplateStage = STAGE_INITIALIZED;
}
return transactionUserTemplate;
}
String transactionUserTemplate(String value) {
this.transactionUserTemplate = value;
transactionUserTemplateStage = STAGE_INITIALIZED;
return value;
}
private String traceEntryMessageTemplate;
private byte traceEntryMessageTemplateStage;
String traceEntryMessageTemplate() {
if (traceEntryMessageTemplateStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (traceEntryMessageTemplateStage == STAGE_UNINITIALIZED) {
traceEntryMessageTemplateStage = STAGE_INITIALIZING;
this.traceEntryMessageTemplate = Preconditions.checkNotNull(ImmutableInstrumentationConfig.super.traceEntryMessageTemplate());
traceEntryMessageTemplateStage = STAGE_INITIALIZED;
}
return traceEntryMessageTemplate;
}
String traceEntryMessageTemplate(String value) {
this.traceEntryMessageTemplate = value;
traceEntryMessageTemplateStage = STAGE_INITIALIZED;
return value;
}
private boolean traceEntryCaptureSelfNested;
private byte traceEntryCaptureSelfNestedStage;
boolean traceEntryCaptureSelfNested() {
if (traceEntryCaptureSelfNestedStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (traceEntryCaptureSelfNestedStage == STAGE_UNINITIALIZED) {
traceEntryCaptureSelfNestedStage = STAGE_INITIALIZING;
this.traceEntryCaptureSelfNested = ImmutableInstrumentationConfig.super.traceEntryCaptureSelfNested();
traceEntryCaptureSelfNestedStage = STAGE_INITIALIZED;
}
return traceEntryCaptureSelfNested;
}
boolean traceEntryCaptureSelfNested(boolean value) {
this.traceEntryCaptureSelfNested = value;
traceEntryCaptureSelfNestedStage = STAGE_INITIALIZED;
return value;
}
private String timerName;
private byte timerNameStage;
String timerName() {
if (timerNameStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (timerNameStage == STAGE_UNINITIALIZED) {
timerNameStage = STAGE_INITIALIZING;
this.timerName = Preconditions.checkNotNull(ImmutableInstrumentationConfig.super.timerName());
timerNameStage = STAGE_INITIALIZED;
}
return timerName;
}
String timerName(String value) {
this.timerName = value;
timerNameStage = STAGE_INITIALIZED;
return value;
}
private String enabledProperty;
private byte enabledPropertyStage;
String enabledProperty() {
if (enabledPropertyStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (enabledPropertyStage == STAGE_UNINITIALIZED) {
enabledPropertyStage = STAGE_INITIALIZING;
this.enabledProperty = Preconditions.checkNotNull(ImmutableInstrumentationConfig.super.enabledProperty());
enabledPropertyStage = STAGE_INITIALIZED;
}
return enabledProperty;
}
String enabledProperty(String value) {
this.enabledProperty = value;
enabledPropertyStage = STAGE_INITIALIZED;
return value;
}
private String traceEntryEnabledProperty;
private byte traceEntryEnabledPropertyStage;
String traceEntryEnabledProperty() {
if (traceEntryEnabledPropertyStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (traceEntryEnabledPropertyStage == STAGE_UNINITIALIZED) {
traceEntryEnabledPropertyStage = STAGE_INITIALIZING;
this.traceEntryEnabledProperty = Preconditions.checkNotNull(ImmutableInstrumentationConfig.super.traceEntryEnabledProperty());
traceEntryEnabledPropertyStage = STAGE_INITIALIZED;
}
return traceEntryEnabledProperty;
}
String traceEntryEnabledProperty(String value) {
this.traceEntryEnabledProperty = value;
traceEntryEnabledPropertyStage = STAGE_INITIALIZED;
return value;
}
private String version;
private byte versionStage;
String version() {
if (versionStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (versionStage == STAGE_UNINITIALIZED) {
versionStage = STAGE_INITIALIZING;
this.version = Preconditions.checkNotNull(ImmutableInstrumentationConfig.super.version());
versionStage = STAGE_INITIALIZED;
}
return version;
}
private boolean isTimerOrGreater;
private byte isTimerOrGreaterStage;
boolean isTimerOrGreater() {
if (isTimerOrGreaterStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (isTimerOrGreaterStage == STAGE_UNINITIALIZED) {
isTimerOrGreaterStage = STAGE_INITIALIZING;
this.isTimerOrGreater = ImmutableInstrumentationConfig.super.isTimerOrGreater();
isTimerOrGreaterStage = STAGE_INITIALIZED;
}
return isTimerOrGreater;
}
private boolean isTraceEntryOrGreater;
private byte isTraceEntryOrGreaterStage;
boolean isTraceEntryOrGreater() {
if (isTraceEntryOrGreaterStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (isTraceEntryOrGreaterStage == STAGE_UNINITIALIZED) {
isTraceEntryOrGreaterStage = STAGE_INITIALIZING;
this.isTraceEntryOrGreater = ImmutableInstrumentationConfig.super.isTraceEntryOrGreater();
isTraceEntryOrGreaterStage = STAGE_INITIALIZED;
}
return isTraceEntryOrGreater;
}
private boolean isTransaction;
private byte isTransactionStage;
boolean isTransaction() {
if (isTransactionStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (isTransactionStage == STAGE_UNINITIALIZED) {
isTransactionStage = STAGE_INITIALIZING;
this.isTransaction = ImmutableInstrumentationConfig.super.isTransaction();
isTransactionStage = STAGE_INITIALIZED;
}
return isTransaction;
}
private ImmutableList validationErrors;
private byte validationErrorsStage;
ImmutableList validationErrors() {
if (validationErrorsStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (validationErrorsStage == STAGE_UNINITIALIZED) {
validationErrorsStage = STAGE_INITIALIZING;
this.validationErrors = Preconditions.checkNotNull(ImmutableInstrumentationConfig.super.validationErrors());
validationErrorsStage = STAGE_INITIALIZED;
}
return validationErrors;
}
private String formatInitCycleMessage() {
ArrayList attributes = Lists.newArrayList();;
if (declaringClassNameStage == STAGE_INITIALIZING) attributes.add("declaringClassName");
if (methodReturnTypeStage == STAGE_INITIALIZING) attributes.add("methodReturnType");
if (transactionTypeStage == STAGE_INITIALIZING) attributes.add("transactionType");
if (transactionNameTemplateStage == STAGE_INITIALIZING) attributes.add("transactionNameTemplate");
if (transactionUserTemplateStage == STAGE_INITIALIZING) attributes.add("transactionUserTemplate");
if (traceEntryMessageTemplateStage == STAGE_INITIALIZING) attributes.add("traceEntryMessageTemplate");
if (traceEntryCaptureSelfNestedStage == STAGE_INITIALIZING) attributes.add("traceEntryCaptureSelfNested");
if (timerNameStage == STAGE_INITIALIZING) attributes.add("timerName");
if (enabledPropertyStage == STAGE_INITIALIZING) attributes.add("enabledProperty");
if (traceEntryEnabledPropertyStage == STAGE_INITIALIZING) attributes.add("traceEntryEnabledProperty");
if (versionStage == STAGE_INITIALIZING) attributes.add("version");
if (isTimerOrGreaterStage == STAGE_INITIALIZING) attributes.add("isTimerOrGreater");
if (isTraceEntryOrGreaterStage == STAGE_INITIALIZING) attributes.add("isTraceEntryOrGreater");
if (isTransactionStage == STAGE_INITIALIZING) attributes.add("isTransaction");
if (validationErrorsStage == STAGE_INITIALIZING) attributes.add("validationErrors");
return "Cannot build InstrumentationConfig, attribute initializers form cycle" + attributes;
}
}
private ImmutableInstrumentationConfig(
String className,
String declaringClassName,
String methodName,
ImmutableList methodParameterTypes,
String methodReturnType,
ImmutableList methodModifiers,
InstrumentationConfig.CaptureKind captureKind,
String transactionType,
String transactionNameTemplate,
String transactionUserTemplate,
ImmutableMap transactionAttributeTemplates,
@Nullable Integer transactionSlowThresholdMillis,
String traceEntryMessageTemplate,
@Nullable Integer traceEntryStackThresholdMillis,
boolean traceEntryCaptureSelfNested,
String timerName,
String enabledProperty,
String traceEntryEnabledProperty) {
this.className = className;
this.declaringClassName = declaringClassName;
this.methodName = methodName;
this.methodParameterTypes = methodParameterTypes;
this.methodReturnType = methodReturnType;
this.methodModifiers = methodModifiers;
this.captureKind = captureKind;
this.transactionType = transactionType;
this.transactionNameTemplate = transactionNameTemplate;
this.transactionUserTemplate = transactionUserTemplate;
this.transactionAttributeTemplates = transactionAttributeTemplates;
this.transactionSlowThresholdMillis = transactionSlowThresholdMillis;
this.traceEntryMessageTemplate = traceEntryMessageTemplate;
this.traceEntryStackThresholdMillis = traceEntryStackThresholdMillis;
this.traceEntryCaptureSelfNested = traceEntryCaptureSelfNested;
this.timerName = timerName;
this.enabledProperty = enabledProperty;
this.traceEntryEnabledProperty = traceEntryEnabledProperty;
this.version = Preconditions.checkNotNull(super.version());
this.isTimerOrGreater = super.isTimerOrGreater();
this.isTraceEntryOrGreater = super.isTraceEntryOrGreater();
this.isTransaction = super.isTransaction();
this.validationErrors = Preconditions.checkNotNull(super.validationErrors());
this.initShim = null;
}
/**
* @return value of {@code className} attribute
*/
@JsonProperty
@Override
public String className() {
return className;
}
/**
* @return value of {@code declaringClassName} attribute
*/
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Override
public String declaringClassName() {
return initShim != null
? initShim.declaringClassName()
: declaringClassName;
}
/**
* @return value of {@code methodName} attribute
*/
@JsonProperty
@Override
public String methodName() {
return methodName;
}
/**
* @return value of {@code methodParameterTypes} attribute
*/
@JsonProperty
@Override
public ImmutableList methodParameterTypes() {
return methodParameterTypes;
}
/**
* @return value of {@code methodReturnType} attribute
*/
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Override
public String methodReturnType() {
return initShim != null
? initShim.methodReturnType()
: methodReturnType;
}
/**
* @return value of {@code methodModifiers} attribute
*/
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Override
public ImmutableList methodModifiers() {
return methodModifiers;
}
/**
* @return value of {@code captureKind} attribute
*/
@JsonProperty
@Override
public InstrumentationConfig.CaptureKind captureKind() {
return captureKind;
}
/**
* @return value of {@code transactionType} attribute
*/
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Override
public String transactionType() {
return initShim != null
? initShim.transactionType()
: transactionType;
}
/**
* @return value of {@code transactionNameTemplate} attribute
*/
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Override
public String transactionNameTemplate() {
return initShim != null
? initShim.transactionNameTemplate()
: transactionNameTemplate;
}
/**
* @return value of {@code transactionUserTemplate} attribute
*/
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Override
public String transactionUserTemplate() {
return initShim != null
? initShim.transactionUserTemplate()
: transactionUserTemplate;
}
/**
* @return value of {@code transactionAttributeTemplates} attribute
*/
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Override
public ImmutableMap transactionAttributeTemplates() {
return transactionAttributeTemplates;
}
/**
* @return value of {@code transactionSlowThresholdMillis} attribute
*/
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_NULL)
@Override
public @Nullable Integer transactionSlowThresholdMillis() {
return transactionSlowThresholdMillis;
}
/**
* @return value of {@code traceEntryMessageTemplate} attribute
*/
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Override
public String traceEntryMessageTemplate() {
return initShim != null
? initShim.traceEntryMessageTemplate()
: traceEntryMessageTemplate;
}
/**
* @return value of {@code traceEntryStackThresholdMillis} attribute
*/
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_NULL)
@Override
public @Nullable Integer traceEntryStackThresholdMillis() {
return traceEntryStackThresholdMillis;
}
/**
* @return value of {@code traceEntryCaptureSelfNested} attribute
*/
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Override
public boolean traceEntryCaptureSelfNested() {
return initShim != null
? initShim.traceEntryCaptureSelfNested()
: traceEntryCaptureSelfNested;
}
/**
* @return value of {@code timerName} attribute
*/
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Override
public String timerName() {
return initShim != null
? initShim.timerName()
: timerName;
}
/**
* @return value of {@code enabledProperty} attribute
*/
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Override
public String enabledProperty() {
return initShim != null
? initShim.enabledProperty()
: enabledProperty;
}
/**
* @return value of {@code traceEntryEnabledProperty} attribute
*/
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Override
public String traceEntryEnabledProperty() {
return initShim != null
? initShim.traceEntryEnabledProperty()
: traceEntryEnabledProperty;
}
/**
* @return computed at construction value of {@code version} attribute
*/
@JsonProperty
@JsonIgnore
@Override
public String version() {
return initShim != null
? initShim.version()
: version;
}
/**
* @return computed at construction value of {@code isTimerOrGreater} attribute
*/
@JsonProperty
@JsonIgnore
@Override
public boolean isTimerOrGreater() {
return initShim != null
? initShim.isTimerOrGreater()
: isTimerOrGreater;
}
/**
* @return computed at construction value of {@code isTraceEntryOrGreater} attribute
*/
@JsonProperty
@JsonIgnore
@Override
public boolean isTraceEntryOrGreater() {
return initShim != null
? initShim.isTraceEntryOrGreater()
: isTraceEntryOrGreater;
}
/**
* @return computed at construction value of {@code isTransaction} attribute
*/
@JsonProperty
@JsonIgnore
@Override
public boolean isTransaction() {
return initShim != null
? initShim.isTransaction()
: isTransaction;
}
/**
* @return computed at construction value of {@code validationErrors} attribute
*/
@JsonProperty
@JsonIgnore
@Override
public ImmutableList validationErrors() {
return initShim != null
? initShim.validationErrors()
: validationErrors;
}
/**
* Copy current immutable object by setting value for {@link InstrumentationConfig#className() className}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for className
* @return modified copy of the {@code this} object
*/
public final ImmutableInstrumentationConfig withClassName(String value) {
if (this.className == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableInstrumentationConfig(
newValue,
this.declaringClassName,
this.methodName,
this.methodParameterTypes,
this.methodReturnType,
this.methodModifiers,
this.captureKind,
this.transactionType,
this.transactionNameTemplate,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
this.timerName,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object by setting value for {@link InstrumentationConfig#declaringClassName() declaringClassName}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for declaringClassName
* @return modified copy of the {@code this} object
*/
public final ImmutableInstrumentationConfig withDeclaringClassName(String value) {
if (this.declaringClassName == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableInstrumentationConfig(
this.className,
newValue,
this.methodName,
this.methodParameterTypes,
this.methodReturnType,
this.methodModifiers,
this.captureKind,
this.transactionType,
this.transactionNameTemplate,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
this.timerName,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object by setting value for {@link InstrumentationConfig#methodName() methodName}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for methodName
* @return modified copy of the {@code this} object
*/
public final ImmutableInstrumentationConfig withMethodName(String value) {
if (this.methodName == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
newValue,
this.methodParameterTypes,
this.methodReturnType,
this.methodModifiers,
this.captureKind,
this.transactionType,
this.transactionNameTemplate,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
this.timerName,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object with elements that replace content of {@link InstrumentationConfig#methodParameterTypes() methodParameterTypes}.
* @param elements elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableInstrumentationConfig withMethodParameterTypes(String... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
this.methodName,
newValue,
this.methodReturnType,
this.methodModifiers,
this.captureKind,
this.transactionType,
this.transactionNameTemplate,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
this.timerName,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object with elements that replace content of {@link InstrumentationConfig#methodParameterTypes() methodParameterTypes}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements iterable of methodParameterTypes elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableInstrumentationConfig withMethodParameterTypes(Iterable elements) {
if (this.methodParameterTypes == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
this.methodName,
newValue,
this.methodReturnType,
this.methodModifiers,
this.captureKind,
this.transactionType,
this.transactionNameTemplate,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
this.timerName,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object by setting value for {@link InstrumentationConfig#methodReturnType() methodReturnType}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for methodReturnType
* @return modified copy of the {@code this} object
*/
public final ImmutableInstrumentationConfig withMethodReturnType(String value) {
if (this.methodReturnType == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
this.methodName,
this.methodParameterTypes,
newValue,
this.methodModifiers,
this.captureKind,
this.transactionType,
this.transactionNameTemplate,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
this.timerName,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object with elements that replace content of {@link InstrumentationConfig#methodModifiers() methodModifiers}.
* @param elements elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableInstrumentationConfig withMethodModifiers(InstrumentationConfig.MethodModifier... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
this.methodName,
this.methodParameterTypes,
this.methodReturnType,
newValue,
this.captureKind,
this.transactionType,
this.transactionNameTemplate,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
this.timerName,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object with elements that replace content of {@link InstrumentationConfig#methodModifiers() methodModifiers}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements iterable of methodModifiers elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableInstrumentationConfig withMethodModifiers(Iterable extends InstrumentationConfig.MethodModifier> elements) {
if (this.methodModifiers == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
this.methodName,
this.methodParameterTypes,
this.methodReturnType,
newValue,
this.captureKind,
this.transactionType,
this.transactionNameTemplate,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
this.timerName,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object by setting value for {@link InstrumentationConfig#captureKind() captureKind}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for captureKind
* @return modified copy of the {@code this} object
*/
public final ImmutableInstrumentationConfig withCaptureKind(InstrumentationConfig.CaptureKind value) {
if (this.captureKind == value) return this;
InstrumentationConfig.CaptureKind newValue = Preconditions.checkNotNull(value);
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
this.methodName,
this.methodParameterTypes,
this.methodReturnType,
this.methodModifiers,
newValue,
this.transactionType,
this.transactionNameTemplate,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
this.timerName,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object by setting value for {@link InstrumentationConfig#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 ImmutableInstrumentationConfig withTransactionType(String value) {
if (this.transactionType == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
this.methodName,
this.methodParameterTypes,
this.methodReturnType,
this.methodModifiers,
this.captureKind,
newValue,
this.transactionNameTemplate,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
this.timerName,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object by setting value for {@link InstrumentationConfig#transactionNameTemplate() transactionNameTemplate}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for transactionNameTemplate
* @return modified copy of the {@code this} object
*/
public final ImmutableInstrumentationConfig withTransactionNameTemplate(String value) {
if (this.transactionNameTemplate == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
this.methodName,
this.methodParameterTypes,
this.methodReturnType,
this.methodModifiers,
this.captureKind,
this.transactionType,
newValue,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
this.timerName,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object by setting value for {@link InstrumentationConfig#transactionUserTemplate() transactionUserTemplate}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for transactionUserTemplate
* @return modified copy of the {@code this} object
*/
public final ImmutableInstrumentationConfig withTransactionUserTemplate(String value) {
if (this.transactionUserTemplate == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
this.methodName,
this.methodParameterTypes,
this.methodReturnType,
this.methodModifiers,
this.captureKind,
this.transactionType,
this.transactionNameTemplate,
newValue,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
this.timerName,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object by replacing {@link InstrumentationConfig#transactionAttributeTemplates() transactionAttributeTemplates} 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 transactionAttributeTemplates map
* @return modified copy of {@code this} object
*/
public final ImmutableInstrumentationConfig withTransactionAttributeTemplates(Map entries) {
if (this.transactionAttributeTemplates == entries) return this;
ImmutableMap newValue = ImmutableMap.copyOf(entries);
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
this.methodName,
this.methodParameterTypes,
this.methodReturnType,
this.methodModifiers,
this.captureKind,
this.transactionType,
this.transactionNameTemplate,
this.transactionUserTemplate,
newValue,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
this.timerName,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object by setting value for {@link InstrumentationConfig#transactionSlowThresholdMillis() transactionSlowThresholdMillis}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for transactionSlowThresholdMillis, can be {@code null}
* @return modified copy of the {@code this} object
*/
public final ImmutableInstrumentationConfig withTransactionSlowThresholdMillis(@Nullable Integer value) {
if (this.transactionSlowThresholdMillis == value) return this;
@Nullable Integer newValue = value;
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
this.methodName,
this.methodParameterTypes,
this.methodReturnType,
this.methodModifiers,
this.captureKind,
this.transactionType,
this.transactionNameTemplate,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
newValue,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
this.timerName,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object by setting value for {@link InstrumentationConfig#traceEntryMessageTemplate() traceEntryMessageTemplate}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for traceEntryMessageTemplate
* @return modified copy of the {@code this} object
*/
public final ImmutableInstrumentationConfig withTraceEntryMessageTemplate(String value) {
if (this.traceEntryMessageTemplate == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
this.methodName,
this.methodParameterTypes,
this.methodReturnType,
this.methodModifiers,
this.captureKind,
this.transactionType,
this.transactionNameTemplate,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
newValue,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
this.timerName,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object by setting value for {@link InstrumentationConfig#traceEntryStackThresholdMillis() traceEntryStackThresholdMillis}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for traceEntryStackThresholdMillis, can be {@code null}
* @return modified copy of the {@code this} object
*/
public final ImmutableInstrumentationConfig withTraceEntryStackThresholdMillis(@Nullable Integer value) {
if (this.traceEntryStackThresholdMillis == value) return this;
@Nullable Integer newValue = value;
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
this.methodName,
this.methodParameterTypes,
this.methodReturnType,
this.methodModifiers,
this.captureKind,
this.transactionType,
this.transactionNameTemplate,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
newValue,
this.traceEntryCaptureSelfNested,
this.timerName,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object by setting value for {@link InstrumentationConfig#traceEntryCaptureSelfNested() traceEntryCaptureSelfNested}.
* Value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for traceEntryCaptureSelfNested
* @return modified copy of the {@code this} object
*/
public final ImmutableInstrumentationConfig withTraceEntryCaptureSelfNested(boolean value) {
if (this.traceEntryCaptureSelfNested == value) return this;
boolean newValue = value;
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
this.methodName,
this.methodParameterTypes,
this.methodReturnType,
this.methodModifiers,
this.captureKind,
this.transactionType,
this.transactionNameTemplate,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
newValue,
this.timerName,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object by setting value for {@link InstrumentationConfig#timerName() timerName}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for timerName
* @return modified copy of the {@code this} object
*/
public final ImmutableInstrumentationConfig withTimerName(String value) {
if (this.timerName == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
this.methodName,
this.methodParameterTypes,
this.methodReturnType,
this.methodModifiers,
this.captureKind,
this.transactionType,
this.transactionNameTemplate,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
newValue,
this.enabledProperty,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object by setting value for {@link InstrumentationConfig#enabledProperty() enabledProperty}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for enabledProperty
* @return modified copy of the {@code this} object
*/
public final ImmutableInstrumentationConfig withEnabledProperty(String value) {
if (this.enabledProperty == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
this.methodName,
this.methodParameterTypes,
this.methodReturnType,
this.methodModifiers,
this.captureKind,
this.transactionType,
this.transactionNameTemplate,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
this.timerName,
newValue,
this.traceEntryEnabledProperty);
}
/**
* Copy current immutable object by setting value for {@link InstrumentationConfig#traceEntryEnabledProperty() traceEntryEnabledProperty}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for traceEntryEnabledProperty
* @return modified copy of the {@code this} object
*/
public final ImmutableInstrumentationConfig withTraceEntryEnabledProperty(String value) {
if (this.traceEntryEnabledProperty == value) return this;
String newValue = Preconditions.checkNotNull(value);
return new ImmutableInstrumentationConfig(
this.className,
this.declaringClassName,
this.methodName,
this.methodParameterTypes,
this.methodReturnType,
this.methodModifiers,
this.captureKind,
this.transactionType,
this.transactionNameTemplate,
this.transactionUserTemplate,
this.transactionAttributeTemplates,
this.transactionSlowThresholdMillis,
this.traceEntryMessageTemplate,
this.traceEntryStackThresholdMillis,
this.traceEntryCaptureSelfNested,
this.timerName,
this.enabledProperty,
newValue);
}
/**
* This instance is equal to instances of {@code ImmutableInstrumentationConfig} 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 ImmutableInstrumentationConfig
&& equalTo((ImmutableInstrumentationConfig) another);
}
private boolean equalTo(ImmutableInstrumentationConfig another) {
return className.equals(another.className)
&& declaringClassName.equals(another.declaringClassName)
&& methodName.equals(another.methodName)
&& methodParameterTypes.equals(another.methodParameterTypes)
&& methodReturnType.equals(another.methodReturnType)
&& methodModifiers.equals(another.methodModifiers)
&& captureKind.equals(another.captureKind)
&& transactionType.equals(another.transactionType)
&& transactionNameTemplate.equals(another.transactionNameTemplate)
&& transactionUserTemplate.equals(another.transactionUserTemplate)
&& transactionAttributeTemplates.equals(another.transactionAttributeTemplates)
&& Objects.equal(transactionSlowThresholdMillis, another.transactionSlowThresholdMillis)
&& traceEntryMessageTemplate.equals(another.traceEntryMessageTemplate)
&& Objects.equal(traceEntryStackThresholdMillis, another.traceEntryStackThresholdMillis)
&& traceEntryCaptureSelfNested == another.traceEntryCaptureSelfNested
&& timerName.equals(another.timerName)
&& enabledProperty.equals(another.enabledProperty)
&& traceEntryEnabledProperty.equals(another.traceEntryEnabledProperty)
&& version.equals(another.version)
&& isTimerOrGreater == another.isTimerOrGreater
&& isTraceEntryOrGreater == another.isTraceEntryOrGreater
&& isTransaction == another.isTransaction
&& validationErrors.equals(another.validationErrors);
}
/**
* Computes hash code from attributes: {@code className}, {@code declaringClassName}, {@code methodName}, {@code methodParameterTypes}, {@code methodReturnType}, {@code methodModifiers}, {@code captureKind}, {@code transactionType}, {@code transactionNameTemplate}, {@code transactionUserTemplate}, {@code transactionAttributeTemplates}, {@code transactionSlowThresholdMillis}, {@code traceEntryMessageTemplate}, {@code traceEntryStackThresholdMillis}, {@code traceEntryCaptureSelfNested}, {@code timerName}, {@code enabledProperty}, {@code traceEntryEnabledProperty}, {@code version}, {@code isTimerOrGreater}, {@code isTraceEntryOrGreater}, {@code isTransaction}, {@code validationErrors}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 31;
h = h * 17 + className.hashCode();
h = h * 17 + declaringClassName.hashCode();
h = h * 17 + methodName.hashCode();
h = h * 17 + methodParameterTypes.hashCode();
h = h * 17 + methodReturnType.hashCode();
h = h * 17 + methodModifiers.hashCode();
h = h * 17 + captureKind.hashCode();
h = h * 17 + transactionType.hashCode();
h = h * 17 + transactionNameTemplate.hashCode();
h = h * 17 + transactionUserTemplate.hashCode();
h = h * 17 + transactionAttributeTemplates.hashCode();
h = h * 17 + Objects.hashCode(transactionSlowThresholdMillis);
h = h * 17 + traceEntryMessageTemplate.hashCode();
h = h * 17 + Objects.hashCode(traceEntryStackThresholdMillis);
h = h * 17 + Booleans.hashCode(traceEntryCaptureSelfNested);
h = h * 17 + timerName.hashCode();
h = h * 17 + enabledProperty.hashCode();
h = h * 17 + traceEntryEnabledProperty.hashCode();
h = h * 17 + version.hashCode();
h = h * 17 + Booleans.hashCode(isTimerOrGreater);
h = h * 17 + Booleans.hashCode(isTraceEntryOrGreater);
h = h * 17 + Booleans.hashCode(isTransaction);
h = h * 17 + validationErrors.hashCode();
return h;
}
/**
* Prints immutable value {@code InstrumentationConfig...} with attribute values,
* excluding any non-generated and auxiliary attributes.
* @return string representation of value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("InstrumentationConfig")
.add("className", className)
.add("declaringClassName", declaringClassName)
.add("methodName", methodName)
.add("methodParameterTypes", methodParameterTypes)
.add("methodReturnType", methodReturnType)
.add("methodModifiers", methodModifiers)
.add("captureKind", captureKind)
.add("transactionType", transactionType)
.add("transactionNameTemplate", transactionNameTemplate)
.add("transactionUserTemplate", transactionUserTemplate)
.add("transactionAttributeTemplates", transactionAttributeTemplates)
.add("transactionSlowThresholdMillis", transactionSlowThresholdMillis)
.add("traceEntryMessageTemplate", traceEntryMessageTemplate)
.add("traceEntryStackThresholdMillis", traceEntryStackThresholdMillis)
.add("traceEntryCaptureSelfNested", traceEntryCaptureSelfNested)
.add("timerName", timerName)
.add("enabledProperty", enabledProperty)
.add("traceEntryEnabledProperty", traceEntryEnabledProperty)
.add("version", version)
.add("isTimerOrGreater", isTimerOrGreater)
.add("isTraceEntryOrGreater", isTraceEntryOrGreater)
.add("isTransaction", isTransaction)
.add("validationErrors", validationErrors)
.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 className;
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Nullable String declaringClassName;
@JsonProperty
@Nullable String methodName;
@JsonProperty
@Nullable ImmutableList methodParameterTypes;
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Nullable String methodReturnType;
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Nullable ImmutableList methodModifiers;
@JsonProperty
@Nullable InstrumentationConfig.CaptureKind captureKind;
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Nullable String transactionType;
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Nullable String transactionNameTemplate;
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Nullable String transactionUserTemplate;
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Nullable Map transactionAttributeTemplates;
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_NULL)
@Nullable Integer transactionSlowThresholdMillis;
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Nullable String traceEntryMessageTemplate;
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_NULL)
@Nullable Integer traceEntryStackThresholdMillis;
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Nullable Boolean traceEntryCaptureSelfNested;
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Nullable String timerName;
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Nullable String enabledProperty;
@JsonProperty
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@Nullable String traceEntryEnabledProperty;
@JsonProperty
@JsonIgnore
@Nullable String version;
@JsonProperty
@JsonIgnore
@Nullable Boolean isTimerOrGreater;
@JsonProperty
@JsonIgnore
@Nullable Boolean isTraceEntryOrGreater;
@JsonProperty
@JsonIgnore
@Nullable Boolean isTransaction;
@JsonProperty
@JsonIgnore
@Nullable ImmutableList validationErrors;
}
/**
* @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 ImmutableInstrumentationConfig fromJson(Json json) {
ImmutableInstrumentationConfig.Builder builder = ImmutableInstrumentationConfig.builder();
if (json.className != null) {
builder.className(json.className);
}
if (json.declaringClassName != null) {
builder.declaringClassName(json.declaringClassName);
}
if (json.methodName != null) {
builder.methodName(json.methodName);
}
if (json.methodParameterTypes != null) {
builder.addAllMethodParameterTypes(json.methodParameterTypes);
}
if (json.methodReturnType != null) {
builder.methodReturnType(json.methodReturnType);
}
if (json.methodModifiers != null) {
builder.addAllMethodModifiers(json.methodModifiers);
}
if (json.captureKind != null) {
builder.captureKind(json.captureKind);
}
if (json.transactionType != null) {
builder.transactionType(json.transactionType);
}
if (json.transactionNameTemplate != null) {
builder.transactionNameTemplate(json.transactionNameTemplate);
}
if (json.transactionUserTemplate != null) {
builder.transactionUserTemplate(json.transactionUserTemplate);
}
if (json.transactionAttributeTemplates != null) {
builder.putAllTransactionAttributeTemplates(json.transactionAttributeTemplates);
}
if (json.transactionSlowThresholdMillis != null) {
builder.transactionSlowThresholdMillis(json.transactionSlowThresholdMillis);
}
if (json.traceEntryMessageTemplate != null) {
builder.traceEntryMessageTemplate(json.traceEntryMessageTemplate);
}
if (json.traceEntryStackThresholdMillis != null) {
builder.traceEntryStackThresholdMillis(json.traceEntryStackThresholdMillis);
}
if (json.traceEntryCaptureSelfNested != null) {
builder.traceEntryCaptureSelfNested(json.traceEntryCaptureSelfNested);
}
if (json.timerName != null) {
builder.timerName(json.timerName);
}
if (json.enabledProperty != null) {
builder.enabledProperty(json.enabledProperty);
}
if (json.traceEntryEnabledProperty != null) {
builder.traceEntryEnabledProperty(json.traceEntryEnabledProperty);
}
return builder.build();
}
/**
* Creates immutable copy of {@link InstrumentationConfig}.
* 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 InstrumentationConfig instance
*/
public static ImmutableInstrumentationConfig copyOf(InstrumentationConfig instance) {
if (instance instanceof ImmutableInstrumentationConfig) {
return (ImmutableInstrumentationConfig) instance;
}
return ImmutableInstrumentationConfig.builder()
.copyFrom(instance)
.build();
}
/**
* Creates builder for {@link org.glowroot.common.config.ImmutableInstrumentationConfig ImmutableInstrumentationConfig}.
* @return new ImmutableInstrumentationConfig builder
*/
public static ImmutableInstrumentationConfig.Builder builder() {
return new ImmutableInstrumentationConfig.Builder();
}
/**
* Builds instances of {@link org.glowroot.common.config.ImmutableInstrumentationConfig ImmutableInstrumentationConfig}.
* 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
public static final class Builder {
private static final long INIT_BIT_CLASS_NAME = 0x1L;
private static final long INIT_BIT_METHOD_NAME = 0x2L;
private static final long INIT_BIT_CAPTURE_KIND = 0x4L;
private static final long OPT_BIT_TRACE_ENTRY_CAPTURE_SELF_NESTED = 0x1L;
private long initBits = 0x7;
private long optBits;
private @Nullable String className;
private @Nullable String declaringClassName;
private @Nullable String methodName;
private ImmutableList.Builder methodParameterTypesBuilder = ImmutableList.builder();
private @Nullable String methodReturnType;
private ImmutableList.Builder methodModifiersBuilder = ImmutableList.builder();
private @Nullable InstrumentationConfig.CaptureKind captureKind;
private @Nullable String transactionType;
private @Nullable String transactionNameTemplate;
private @Nullable String transactionUserTemplate;
private ImmutableMap.Builder transactionAttributeTemplatesBuilder = ImmutableMap.builder();
private @Nullable Integer transactionSlowThresholdMillis;
private @Nullable String traceEntryMessageTemplate;
private @Nullable Integer traceEntryStackThresholdMillis;
private boolean traceEntryCaptureSelfNested;
private @Nullable String timerName;
private @Nullable String enabledProperty;
private @Nullable String traceEntryEnabledProperty;
private Builder() {}
/**
* Fill builder with attribute values from provided {@link InstrumentationConfig} 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(InstrumentationConfig instance) {
Preconditions.checkNotNull(instance);
className(instance.className());
declaringClassName(instance.declaringClassName());
methodName(instance.methodName());
addAllMethodParameterTypes(instance.methodParameterTypes());
methodReturnType(instance.methodReturnType());
addAllMethodModifiers(instance.methodModifiers());
captureKind(instance.captureKind());
transactionType(instance.transactionType());
transactionNameTemplate(instance.transactionNameTemplate());
transactionUserTemplate(instance.transactionUserTemplate());
putAllTransactionAttributeTemplates(instance.transactionAttributeTemplates());
@Nullable Integer transactionSlowThresholdMillisValue = instance.transactionSlowThresholdMillis();
if (transactionSlowThresholdMillisValue != null) {
transactionSlowThresholdMillis(transactionSlowThresholdMillisValue);
}
traceEntryMessageTemplate(instance.traceEntryMessageTemplate());
@Nullable Integer traceEntryStackThresholdMillisValue = instance.traceEntryStackThresholdMillis();
if (traceEntryStackThresholdMillisValue != null) {
traceEntryStackThresholdMillis(traceEntryStackThresholdMillisValue);
}
traceEntryCaptureSelfNested(instance.traceEntryCaptureSelfNested());
timerName(instance.timerName());
enabledProperty(instance.enabledProperty());
traceEntryEnabledProperty(instance.traceEntryEnabledProperty());
return this;
}
/**
* Initializes value for {@link InstrumentationConfig#className() className}.
* @param className value for className
* @return {@code this} builder for chained invocation
*/
public final Builder className(String className) {
this.className = Preconditions.checkNotNull(className);
initBits &= ~INIT_BIT_CLASS_NAME;
return this;
}
/**
* Initializes value for {@link InstrumentationConfig#declaringClassName() declaringClassName}.
* If not set, this attribute will have default value returned by initializer of {@link InstrumentationConfig#declaringClassName() declaringClassName}.
* @param declaringClassName value for declaringClassName
* @return {@code this} builder for chained invocation
*/
public final Builder declaringClassName(String declaringClassName) {
this.declaringClassName = Preconditions.checkNotNull(declaringClassName);
return this;
}
/**
* Initializes value for {@link InstrumentationConfig#methodName() methodName}.
* @param methodName value for methodName
* @return {@code this} builder for chained invocation
*/
public final Builder methodName(String methodName) {
this.methodName = Preconditions.checkNotNull(methodName);
initBits &= ~INIT_BIT_METHOD_NAME;
return this;
}
/**
* Adds one element to {@link InstrumentationConfig#methodParameterTypes() methodParameterTypes} list.
* @param element methodParameterTypes element
* @return {@code this} builder for chained invocation
*/
public final Builder addMethodParameterTypes(String element) {
methodParameterTypesBuilder.add(element);
return this;
}
/**
* Adds elements to {@link InstrumentationConfig#methodParameterTypes() methodParameterTypes} list.
* @param elements array of methodParameterTypes elements
* @return {@code this} builder for chained invocation
*/
public final Builder addMethodParameterTypes(String... elements) {
methodParameterTypesBuilder.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link InstrumentationConfig#methodParameterTypes() methodParameterTypes} list.
* @param elements iterable of methodParameterTypes elements
* @return {@code this} builder for chained invocation
*/
public final Builder methodParameterTypes(Iterable elements) {
methodParameterTypesBuilder = ImmutableList.builder();
return addAllMethodParameterTypes(elements);
}
/**
* Adds elements to {@link InstrumentationConfig#methodParameterTypes() methodParameterTypes} list.
* @param elements iterable of methodParameterTypes elements
* @return {@code this} builder for chained invocation
*/
public final Builder addAllMethodParameterTypes(Iterable elements) {
methodParameterTypesBuilder.addAll(elements);
return this;
}
/**
* Initializes value for {@link InstrumentationConfig#methodReturnType() methodReturnType}.
* If not set, this attribute will have default value returned by initializer of {@link InstrumentationConfig#methodReturnType() methodReturnType}.
* @param methodReturnType value for methodReturnType
* @return {@code this} builder for chained invocation
*/
public final Builder methodReturnType(String methodReturnType) {
this.methodReturnType = Preconditions.checkNotNull(methodReturnType);
return this;
}
/**
* Adds one element to {@link InstrumentationConfig#methodModifiers() methodModifiers} list.
* @param element methodModifiers element
* @return {@code this} builder for chained invocation
*/
public final Builder addMethodModifiers(InstrumentationConfig.MethodModifier element) {
methodModifiersBuilder.add(element);
return this;
}
/**
* Adds elements to {@link InstrumentationConfig#methodModifiers() methodModifiers} list.
* @param elements array of methodModifiers elements
* @return {@code this} builder for chained invocation
*/
public final Builder addMethodModifiers(InstrumentationConfig.MethodModifier... elements) {
methodModifiersBuilder.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link InstrumentationConfig#methodModifiers() methodModifiers} list.
* @param elements iterable of methodModifiers elements
* @return {@code this} builder for chained invocation
*/
public final Builder methodModifiers(Iterable extends InstrumentationConfig.MethodModifier> elements) {
methodModifiersBuilder = ImmutableList.builder();
return addAllMethodModifiers(elements);
}
/**
* Adds elements to {@link InstrumentationConfig#methodModifiers() methodModifiers} list.
* @param elements iterable of methodModifiers elements
* @return {@code this} builder for chained invocation
*/
public final Builder addAllMethodModifiers(Iterable extends InstrumentationConfig.MethodModifier> elements) {
methodModifiersBuilder.addAll(elements);
return this;
}
/**
* Initializes value for {@link InstrumentationConfig#captureKind() captureKind}.
* @param captureKind value for captureKind
* @return {@code this} builder for chained invocation
*/
public final Builder captureKind(InstrumentationConfig.CaptureKind captureKind) {
this.captureKind = Preconditions.checkNotNull(captureKind);
initBits &= ~INIT_BIT_CAPTURE_KIND;
return this;
}
/**
* Initializes value for {@link InstrumentationConfig#transactionType() transactionType}.
*
If not set, this attribute will have default value returned by initializer of {@link InstrumentationConfig#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);
return this;
}
/**
* Initializes value for {@link InstrumentationConfig#transactionNameTemplate() transactionNameTemplate}.
*
If not set, this attribute will have default value returned by initializer of {@link InstrumentationConfig#transactionNameTemplate() transactionNameTemplate}.
* @param transactionNameTemplate value for transactionNameTemplate
* @return {@code this} builder for chained invocation
*/
public final Builder transactionNameTemplate(String transactionNameTemplate) {
this.transactionNameTemplate = Preconditions.checkNotNull(transactionNameTemplate);
return this;
}
/**
* Initializes value for {@link InstrumentationConfig#transactionUserTemplate() transactionUserTemplate}.
*
If not set, this attribute will have default value returned by initializer of {@link InstrumentationConfig#transactionUserTemplate() transactionUserTemplate}.
* @param transactionUserTemplate value for transactionUserTemplate
* @return {@code this} builder for chained invocation
*/
public final Builder transactionUserTemplate(String transactionUserTemplate) {
this.transactionUserTemplate = Preconditions.checkNotNull(transactionUserTemplate);
return this;
}
/**
* Put one entry to {@link InstrumentationConfig#transactionAttributeTemplates() transactionAttributeTemplates} map.
* @param key the key in transactionAttributeTemplates map
* @param value the associated value in transactionAttributeTemplates map
* @return {@code this} builder for chained invocation
*/
public final Builder putTransactionAttributeTemplates(String key, String value) {
transactionAttributeTemplatesBuilder.put(key, value);
return this;
}
/**
* Put one entry to {@link InstrumentationConfig#transactionAttributeTemplates() transactionAttributeTemplates} map. Nulls are not permitted
* @param entry the key and value entry
* @return {@code this} builder for chained invocation
*/
public final Builder putTransactionAttributeTemplates(Map.Entry entry) {
transactionAttributeTemplatesBuilder.put(entry);
return this;
}
/**
* Sets or replaces all mappings from specified map as entries for {@link InstrumentationConfig#transactionAttributeTemplates() transactionAttributeTemplates} map. Nulls are not permitted
* @param entries to be added to transactionAttributeTemplates map
* @return {@code this} builder for chained invocation
*/
public final Builder transactionAttributeTemplates(Map entries) {
transactionAttributeTemplatesBuilder = ImmutableMap.builder();
return putAllTransactionAttributeTemplates(entries);
}
/**
* Put all mappings from specified map as entries to {@link InstrumentationConfig#transactionAttributeTemplates() transactionAttributeTemplates} map. Nulls are not permitted
* @param entries to be added to transactionAttributeTemplates map
* @return {@code this} builder for chained invocation
*/
public final Builder putAllTransactionAttributeTemplates(Map entries) {
transactionAttributeTemplatesBuilder.putAll(entries);
return this;
}
/**
* Initializes value for {@link InstrumentationConfig#transactionSlowThresholdMillis() transactionSlowThresholdMillis}.
* @param transactionSlowThresholdMillis value for transactionSlowThresholdMillis, can be {@code null}
* @return {@code this} builder for chained invocation
*/
public final Builder transactionSlowThresholdMillis(@Nullable Integer transactionSlowThresholdMillis) {
this.transactionSlowThresholdMillis = transactionSlowThresholdMillis;
return this;
}
/**
* Initializes value for {@link InstrumentationConfig#traceEntryMessageTemplate() traceEntryMessageTemplate}.
* If not set, this attribute will have default value returned by initializer of {@link InstrumentationConfig#traceEntryMessageTemplate() traceEntryMessageTemplate}.
* @param traceEntryMessageTemplate value for traceEntryMessageTemplate
* @return {@code this} builder for chained invocation
*/
public final Builder traceEntryMessageTemplate(String traceEntryMessageTemplate) {
this.traceEntryMessageTemplate = Preconditions.checkNotNull(traceEntryMessageTemplate);
return this;
}
/**
* Initializes value for {@link InstrumentationConfig#traceEntryStackThresholdMillis() traceEntryStackThresholdMillis}.
* @param traceEntryStackThresholdMillis value for traceEntryStackThresholdMillis, can be {@code null}
* @return {@code this} builder for chained invocation
*/
public final Builder traceEntryStackThresholdMillis(@Nullable Integer traceEntryStackThresholdMillis) {
this.traceEntryStackThresholdMillis = traceEntryStackThresholdMillis;
return this;
}
/**
* Initializes value for {@link InstrumentationConfig#traceEntryCaptureSelfNested() traceEntryCaptureSelfNested}.
*
If not set, this attribute will have default value returned by initializer of {@link InstrumentationConfig#traceEntryCaptureSelfNested() traceEntryCaptureSelfNested}.
* @param traceEntryCaptureSelfNested value for traceEntryCaptureSelfNested
* @return {@code this} builder for chained invocation
*/
public final Builder traceEntryCaptureSelfNested(boolean traceEntryCaptureSelfNested) {
this.traceEntryCaptureSelfNested = traceEntryCaptureSelfNested;
optBits |= OPT_BIT_TRACE_ENTRY_CAPTURE_SELF_NESTED;
return this;
}
/**
* Initializes value for {@link InstrumentationConfig#timerName() timerName}.
*
If not set, this attribute will have default value returned by initializer of {@link InstrumentationConfig#timerName() timerName}.
* @param timerName value for timerName
* @return {@code this} builder for chained invocation
*/
public final Builder timerName(String timerName) {
this.timerName = Preconditions.checkNotNull(timerName);
return this;
}
/**
* Initializes value for {@link InstrumentationConfig#enabledProperty() enabledProperty}.
*
If not set, this attribute will have default value returned by initializer of {@link InstrumentationConfig#enabledProperty() enabledProperty}.
* @param enabledProperty value for enabledProperty
* @return {@code this} builder for chained invocation
*/
public final Builder enabledProperty(String enabledProperty) {
this.enabledProperty = Preconditions.checkNotNull(enabledProperty);
return this;
}
/**
* Initializes value for {@link InstrumentationConfig#traceEntryEnabledProperty() traceEntryEnabledProperty}.
*
If not set, this attribute will have default value returned by initializer of {@link InstrumentationConfig#traceEntryEnabledProperty() traceEntryEnabledProperty}.
* @param traceEntryEnabledProperty value for traceEntryEnabledProperty
* @return {@code this} builder for chained invocation
*/
public final Builder traceEntryEnabledProperty(String traceEntryEnabledProperty) {
this.traceEntryEnabledProperty = Preconditions.checkNotNull(traceEntryEnabledProperty);
return this;
}
/**
* Builds new {@link org.glowroot.common.config.ImmutableInstrumentationConfig ImmutableInstrumentationConfig}.
* @return immutable instance of InstrumentationConfig
* @throws exception {@code java.lang.IllegalStateException} if any required attributes are missing
*/
public ImmutableInstrumentationConfig build()
throws IllegalStateException {
checkRequiredAttributes(); return new ImmutableInstrumentationConfig(this);
}
private boolean traceEntryCaptureSelfNestedIsSet() {
return (optBits & OPT_BIT_TRACE_ENTRY_CAPTURE_SELF_NESTED) != 0;
}
private boolean classNameIsSet() {
return (initBits & INIT_BIT_CLASS_NAME) == 0;
}
private boolean methodNameIsSet() {
return (initBits & INIT_BIT_METHOD_NAME) == 0;
}
private boolean captureKindIsSet() {
return (initBits & INIT_BIT_CAPTURE_KIND) == 0;
}
private void checkRequiredAttributes() throws IllegalStateException {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = Lists.newArrayList();
if (!classNameIsSet()) attributes.add("className");
if (!methodNameIsSet()) attributes.add("methodName");
if (!captureKindIsSet()) attributes.add("captureKind");
return "Cannot build InstrumentationConfig, some of required attributes are not set " + attributes;
}
}
}