
org.glowroot.ui.ImmutableInstrumentationListResponse Maven / Gradle / Ivy
package org.glowroot.ui;
import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonCreator;
import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonProperty;
import org.glowroot.agent.shaded.google.common.base.MoreObjects;
import org.glowroot.agent.shaded.google.common.base.Preconditions;
import org.glowroot.agent.shaded.google.common.collect.ImmutableList;
import org.glowroot.agent.shaded.google.common.collect.Lists;
import org.glowroot.agent.shaded.google.common.primitives.Booleans;
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 InstrumentationConfigJsonService.InstrumentationListResponse}.
*
* Use builder to create immutable instances:
* {@code ImmutableInstrumentationListResponse.builder()}.
*/
@SuppressWarnings("all")
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "InstrumentationConfigJsonService.InstrumentationListResponse"})
@Immutable
final class ImmutableInstrumentationListResponse
implements InstrumentationConfigJsonService.InstrumentationListResponse {
private final ImmutableList configs;
private final boolean jvmOutOfSync;
private final boolean jvmRetransformClassesSupported;
private ImmutableInstrumentationListResponse(
ImmutableList configs,
boolean jvmOutOfSync,
boolean jvmRetransformClassesSupported) {
this.configs = configs;
this.jvmOutOfSync = jvmOutOfSync;
this.jvmRetransformClassesSupported = jvmRetransformClassesSupported;
}
/**
* @return value of {@code configs} attribute
*/
@JsonProperty
@Override
public ImmutableList configs() {
return configs;
}
/**
* @return value of {@code jvmOutOfSync} attribute
*/
@JsonProperty
@Override
public boolean jvmOutOfSync() {
return jvmOutOfSync;
}
/**
* @return value of {@code jvmRetransformClassesSupported} attribute
*/
@JsonProperty
@Override
public boolean jvmRetransformClassesSupported() {
return jvmRetransformClassesSupported;
}
/**
* Copy current immutable object with elements that replace content of {@link InstrumentationConfigJsonService.InstrumentationListResponse#configs() configs}.
* @param elements elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableInstrumentationListResponse withConfigs(InstrumentationConfigJsonService.InstrumentationConfigDto... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableInstrumentationListResponse(newValue, this.jvmOutOfSync, this.jvmRetransformClassesSupported);
}
/**
* Copy current immutable object with elements that replace content of {@link InstrumentationConfigJsonService.InstrumentationListResponse#configs() configs}.
* Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements iterable of configs elements to set
* @return modified copy of {@code this} object
*/
public final ImmutableInstrumentationListResponse withConfigs(Iterable extends InstrumentationConfigJsonService.InstrumentationConfigDto> elements) {
if (this.configs == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableInstrumentationListResponse(newValue, this.jvmOutOfSync, this.jvmRetransformClassesSupported);
}
/**
* Copy current immutable object by setting value for {@link InstrumentationConfigJsonService.InstrumentationListResponse#jvmOutOfSync() jvmOutOfSync}.
* Value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for jvmOutOfSync
* @return modified copy of the {@code this} object
*/
public final ImmutableInstrumentationListResponse withJvmOutOfSync(boolean value) {
if (this.jvmOutOfSync == value) return this;
boolean newValue = value;
return new ImmutableInstrumentationListResponse(this.configs, newValue, this.jvmRetransformClassesSupported);
}
/**
* Copy current immutable object by setting value for {@link InstrumentationConfigJsonService.InstrumentationListResponse#jvmRetransformClassesSupported() jvmRetransformClassesSupported}.
* Value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value new value for jvmRetransformClassesSupported
* @return modified copy of the {@code this} object
*/
public final ImmutableInstrumentationListResponse withJvmRetransformClassesSupported(boolean value) {
if (this.jvmRetransformClassesSupported == value) return this;
boolean newValue = value;
return new ImmutableInstrumentationListResponse(this.configs, this.jvmOutOfSync, newValue);
}
/**
* This instance is equal to instances of {@code ImmutableInstrumentationListResponse} 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 ImmutableInstrumentationListResponse
&& equalTo((ImmutableInstrumentationListResponse) another);
}
private boolean equalTo(ImmutableInstrumentationListResponse another) {
return configs.equals(another.configs)
&& jvmOutOfSync == another.jvmOutOfSync
&& jvmRetransformClassesSupported == another.jvmRetransformClassesSupported;
}
/**
* Computes hash code from attributes: {@code configs}, {@code jvmOutOfSync}, {@code jvmRetransformClassesSupported}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 31;
h = h * 17 + configs.hashCode();
h = h * 17 + Booleans.hashCode(jvmOutOfSync);
h = h * 17 + Booleans.hashCode(jvmRetransformClassesSupported);
return h;
}
/**
* Prints immutable value {@code InstrumentationListResponse...} with attribute values,
* excluding any non-generated and auxiliary attributes.
* @return string representation of value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("InstrumentationListResponse")
.add("configs", configs)
.add("jvmOutOfSync", jvmOutOfSync)
.add("jvmRetransformClassesSupported", jvmRetransformClassesSupported)
.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 ImmutableList configs;
@JsonProperty
@Nullable Boolean jvmOutOfSync;
@JsonProperty
@Nullable Boolean jvmRetransformClassesSupported;
}
/**
* @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 ImmutableInstrumentationListResponse fromJson(Json json) {
ImmutableInstrumentationListResponse.Builder builder = ImmutableInstrumentationListResponse.builder();
if (json.configs != null) {
builder.addAllConfigs(json.configs);
}
if (json.jvmOutOfSync != null) {
builder.jvmOutOfSync(json.jvmOutOfSync);
}
if (json.jvmRetransformClassesSupported != null) {
builder.jvmRetransformClassesSupported(json.jvmRetransformClassesSupported);
}
return builder.build();
}
/**
* Creates immutable copy of {@link InstrumentationConfigJsonService.InstrumentationListResponse}.
* 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 InstrumentationListResponse instance
*/
static ImmutableInstrumentationListResponse copyOf(InstrumentationConfigJsonService.InstrumentationListResponse instance) {
if (instance instanceof ImmutableInstrumentationListResponse) {
return (ImmutableInstrumentationListResponse) instance;
}
return ImmutableInstrumentationListResponse.builder()
.copyFrom(instance)
.build();
}
/**
* Creates builder for {@link org.glowroot.ui.ImmutableInstrumentationListResponse ImmutableInstrumentationListResponse}.
* @return new ImmutableInstrumentationListResponse builder
*/
static ImmutableInstrumentationListResponse.Builder builder() {
return new ImmutableInstrumentationListResponse.Builder();
}
/**
* Builds instances of {@link org.glowroot.ui.ImmutableInstrumentationListResponse ImmutableInstrumentationListResponse}.
* 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_JVM_OUT_OF_SYNC = 0x1L;
private static final long INIT_BIT_JVM_RETRANSFORM_CLASSES_SUPPORTED = 0x2L;
private long initBits = 0x3;
private ImmutableList.Builder configsBuilder = ImmutableList.builder();
private boolean jvmOutOfSync;
private boolean jvmRetransformClassesSupported;
private Builder() {}
/**
* Fill builder with attribute values from provided {@link InstrumentationConfigJsonService.InstrumentationListResponse} 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(InstrumentationConfigJsonService.InstrumentationListResponse instance) {
Preconditions.checkNotNull(instance);
addAllConfigs(instance.configs());
jvmOutOfSync(instance.jvmOutOfSync());
jvmRetransformClassesSupported(instance.jvmRetransformClassesSupported());
return this;
}
/**
* Adds one element to {@link InstrumentationConfigJsonService.InstrumentationListResponse#configs() configs} list.
* @param element configs element
* @return {@code this} builder for chained invocation
*/
public final Builder addConfigs(InstrumentationConfigJsonService.InstrumentationConfigDto element) {
configsBuilder.add(element);
return this;
}
/**
* Adds elements to {@link InstrumentationConfigJsonService.InstrumentationListResponse#configs() configs} list.
* @param elements array of configs elements
* @return {@code this} builder for chained invocation
*/
public final Builder addConfigs(InstrumentationConfigJsonService.InstrumentationConfigDto... elements) {
configsBuilder.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link InstrumentationConfigJsonService.InstrumentationListResponse#configs() configs} list.
* @param elements iterable of configs elements
* @return {@code this} builder for chained invocation
*/
public final Builder configs(Iterable extends InstrumentationConfigJsonService.InstrumentationConfigDto> elements) {
configsBuilder = ImmutableList.builder();
return addAllConfigs(elements);
}
/**
* Adds elements to {@link InstrumentationConfigJsonService.InstrumentationListResponse#configs() configs} list.
* @param elements iterable of configs elements
* @return {@code this} builder for chained invocation
*/
public final Builder addAllConfigs(Iterable extends InstrumentationConfigJsonService.InstrumentationConfigDto> elements) {
configsBuilder.addAll(elements);
return this;
}
/**
* Initializes value for {@link InstrumentationConfigJsonService.InstrumentationListResponse#jvmOutOfSync() jvmOutOfSync}.
* @param jvmOutOfSync value for jvmOutOfSync
* @return {@code this} builder for chained invocation
*/
public final Builder jvmOutOfSync(boolean jvmOutOfSync) {
this.jvmOutOfSync = jvmOutOfSync;
initBits &= ~INIT_BIT_JVM_OUT_OF_SYNC;
return this;
}
/**
* Initializes value for {@link InstrumentationConfigJsonService.InstrumentationListResponse#jvmRetransformClassesSupported() jvmRetransformClassesSupported}.
* @param jvmRetransformClassesSupported value for jvmRetransformClassesSupported
* @return {@code this} builder for chained invocation
*/
public final Builder jvmRetransformClassesSupported(boolean jvmRetransformClassesSupported) {
this.jvmRetransformClassesSupported = jvmRetransformClassesSupported;
initBits &= ~INIT_BIT_JVM_RETRANSFORM_CLASSES_SUPPORTED;
return this;
}
/**
* Builds new {@link org.glowroot.ui.ImmutableInstrumentationListResponse ImmutableInstrumentationListResponse}.
* @return immutable instance of InstrumentationListResponse
* @throws exception {@code java.lang.IllegalStateException} if any required attributes are missing
*/
public ImmutableInstrumentationListResponse build()
throws IllegalStateException {
checkRequiredAttributes();
return new ImmutableInstrumentationListResponse(configsBuilder.build(), jvmOutOfSync, jvmRetransformClassesSupported);
}
private boolean jvmOutOfSyncIsSet() {
return (initBits & INIT_BIT_JVM_OUT_OF_SYNC) == 0;
}
private boolean jvmRetransformClassesSupportedIsSet() {
return (initBits & INIT_BIT_JVM_RETRANSFORM_CLASSES_SUPPORTED) == 0;
}
private void checkRequiredAttributes() throws IllegalStateException {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = Lists.newArrayList();
if (!jvmOutOfSyncIsSet()) attributes.add("jvmOutOfSync");
if (!jvmRetransformClassesSupportedIsSet()) attributes.add("jvmRetransformClassesSupported");
return "Cannot build InstrumentationListResponse, some of required attributes are not set " + attributes;
}
}
}