
org.glowroot.ui.ImmutablePluginConfigRequest 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.Optional;
import org.glowroot.agent.shaded.google.common.base.Preconditions;
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 ConfigJsonService.PluginConfigRequest}.
*
* Use builder to create immutable instances:
* {@code ImmutablePluginConfigRequest.builder()}.
*/
@SuppressWarnings("all")
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "ConfigJsonService.PluginConfigRequest"})
@Immutable
final class ImmutablePluginConfigRequest
implements ConfigJsonService.PluginConfigRequest {
private final Optional pluginId;
private ImmutablePluginConfigRequest(Optional pluginId) {
this.pluginId = pluginId;
}
/**
* @return value of {@code pluginId} attribute
*/
@JsonProperty
@Override
public Optional pluginId() {
return pluginId;
}
/**
* Copy current immutable object by setting present value for optional {@link ConfigJsonService.PluginConfigRequest#pluginId() pluginId}.
* @param value value for pluginId
* @return modified copy of {@code this} object
*/
public final ImmutablePluginConfigRequest withPluginId(String value) {
Optional newValue = Optional.of(value);
return new ImmutablePluginConfigRequest(newValue);
}
/**
* Copy current immutable object by setting optional value for {@link ConfigJsonService.PluginConfigRequest#pluginId() pluginId}.
* Shallow reference equality check on optional value is used to prevent copying of the same value by returning {@code this}.
* @param optional value for pluginId
* @return modified copy of {@code this} object
*/
public final ImmutablePluginConfigRequest withPluginId(Optional optional) {
if (this.pluginId == optional) return this;
Optional newValue = Preconditions.checkNotNull(optional);
return new ImmutablePluginConfigRequest(newValue);
}
/**
* This instance is equal to instances of {@code ImmutablePluginConfigRequest} 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 ImmutablePluginConfigRequest
&& equalTo((ImmutablePluginConfigRequest) another);
}
private boolean equalTo(ImmutablePluginConfigRequest another) {
return pluginId.equals(another.pluginId);
}
/**
* Computes hash code from attributes: {@code pluginId}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 31;
h = h * 17 + pluginId.hashCode();
return h;
}
/**
* Prints immutable value {@code PluginConfigRequest...} with attribute values,
* excluding any non-generated and auxiliary attributes.
* @return string representation of value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("PluginConfigRequest")
.add("pluginId", pluginId)
.toString();
}
/**
* Simple representation of this value type suitable Jackson binding
* @deprecated Do not use this type directly, it exists only for Jackson-binding infrastructure
*/
@Deprecated
static final class Json {
@JsonProperty
@Nullable Optional pluginId;
}
/**
* @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 ImmutablePluginConfigRequest fromJson(Json json) {
ImmutablePluginConfigRequest.Builder builder = ImmutablePluginConfigRequest.builder();
if (json.pluginId != null) {
builder.pluginId(json.pluginId);
}
return builder.build();
}
/**
* Creates immutable copy of {@link ConfigJsonService.PluginConfigRequest}.
* 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 PluginConfigRequest instance
*/
static ImmutablePluginConfigRequest copyOf(ConfigJsonService.PluginConfigRequest instance) {
if (instance instanceof ImmutablePluginConfigRequest) {
return (ImmutablePluginConfigRequest) instance;
}
return ImmutablePluginConfigRequest.builder()
.copyFrom(instance)
.build();
}
/**
* Creates builder for {@link org.glowroot.ui.ImmutablePluginConfigRequest ImmutablePluginConfigRequest}.
* @return new ImmutablePluginConfigRequest builder
*/
static ImmutablePluginConfigRequest.Builder builder() {
return new ImmutablePluginConfigRequest.Builder();
}
/**
* Builds instances of {@link org.glowroot.ui.ImmutablePluginConfigRequest ImmutablePluginConfigRequest}.
* 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 Optional pluginId = Optional.absent();
private Builder() {}
/**
* Fill builder with attribute values from provided {@link ConfigJsonService.PluginConfigRequest} instance.
* Regular attribute values will be replaced with ones of an instance.
* Instance's absent optional values will not replace present values.
* @param instance instance to copy values from
* @return {@code this} builder for chained invocation
*/
public final Builder copyFrom(ConfigJsonService.PluginConfigRequest instance) {
Preconditions.checkNotNull(instance);
Optional pluginIdOptional = instance.pluginId();
if (pluginIdOptional.isPresent()) {
pluginId(pluginIdOptional);
}
return this;
}
/**
* Initializes present value for optional {@link ConfigJsonService.PluginConfigRequest#pluginId() pluginId}.
* @param pluginId value for pluginId
* @return {@code this} builder for chained invocation
*/
public final Builder pluginId(String pluginId) {
this.pluginId = Optional.of(pluginId);
return this;
}
/**
* Initializes optional value for {@link ConfigJsonService.PluginConfigRequest#pluginId() pluginId}.
* @param pluginId value for pluginId
* @return {@code this} builder for chained invocation
*/
public final Builder pluginId(Optional pluginId) {
this.pluginId = Preconditions.checkNotNull(pluginId);
return this;
}
/**
* Builds new {@link org.glowroot.ui.ImmutablePluginConfigRequest ImmutablePluginConfigRequest}.
* @return immutable instance of PluginConfigRequest
* @throws exception {@code java.lang.IllegalStateException} if any required attributes are missing
*/
public ImmutablePluginConfigRequest build()
throws IllegalStateException {
return new ImmutablePluginConfigRequest(pluginId);
}
}
}