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

org.glowroot.ui.ImmutableInstrumentationErrorResponse Maven / Gradle / Ivy

There is a newer version: 0.9.28
Show newest version
package org.glowroot.ui;

import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonCreator;
import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonProperty;
import org.glowroot.agent.shaded.google.common.base.MoreObjects;
import org.glowroot.agent.shaded.google.common.base.Preconditions;
import org.glowroot.agent.shaded.google.common.collect.ImmutableList;
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.InstrumentationErrorResponse}.
 * 

* Use builder to create immutable instances: * {@code ImmutableInstrumentationErrorResponse.builder()}. */ @SuppressWarnings("all") @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "InstrumentationConfigJsonService.InstrumentationErrorResponse"}) @Immutable final class ImmutableInstrumentationErrorResponse implements InstrumentationConfigJsonService.InstrumentationErrorResponse { private final ImmutableList errors; private ImmutableInstrumentationErrorResponse(ImmutableList errors) { this.errors = errors; } /** * @return value of {@code errors} attribute */ @JsonProperty @Override public ImmutableList errors() { return errors; } /** * Copy current immutable object with elements that replace content of {@link InstrumentationConfigJsonService.InstrumentationErrorResponse#errors() errors}. * @param elements elements to set * @return modified copy of {@code this} object */ public final ImmutableInstrumentationErrorResponse withErrors(String... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableInstrumentationErrorResponse(newValue); } /** * Copy current immutable object with elements that replace content of {@link InstrumentationConfigJsonService.InstrumentationErrorResponse#errors() errors}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements iterable of errors elements to set * @return modified copy of {@code this} object */ public final ImmutableInstrumentationErrorResponse withErrors(Iterable elements) { if (this.errors == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableInstrumentationErrorResponse(newValue); } /** * This instance is equal to instances of {@code ImmutableInstrumentationErrorResponse} 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 ImmutableInstrumentationErrorResponse && equalTo((ImmutableInstrumentationErrorResponse) another); } private boolean equalTo(ImmutableInstrumentationErrorResponse another) { return errors.equals(another.errors); } /** * Computes hash code from attributes: {@code errors}. * @return hashCode value */ @Override public int hashCode() { int h = 31; h = h * 17 + errors.hashCode(); return h; } /** * Prints immutable value {@code InstrumentationErrorResponse...} with attribute values, * excluding any non-generated and auxiliary attributes. * @return string representation of value */ @Override public String toString() { return MoreObjects.toStringHelper("InstrumentationErrorResponse") .add("errors", errors) .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 errors; } /** * @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 ImmutableInstrumentationErrorResponse fromJson(Json json) { ImmutableInstrumentationErrorResponse.Builder builder = ImmutableInstrumentationErrorResponse.builder(); if (json.errors != null) { builder.addAllErrors(json.errors); } return builder.build(); } /** * Creates immutable copy of {@link InstrumentationConfigJsonService.InstrumentationErrorResponse}. * 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 InstrumentationErrorResponse instance */ static ImmutableInstrumentationErrorResponse copyOf(InstrumentationConfigJsonService.InstrumentationErrorResponse instance) { if (instance instanceof ImmutableInstrumentationErrorResponse) { return (ImmutableInstrumentationErrorResponse) instance; } return ImmutableInstrumentationErrorResponse.builder() .copyFrom(instance) .build(); } /** * Creates builder for {@link org.glowroot.ui.ImmutableInstrumentationErrorResponse ImmutableInstrumentationErrorResponse}. * @return new ImmutableInstrumentationErrorResponse builder */ static ImmutableInstrumentationErrorResponse.Builder builder() { return new ImmutableInstrumentationErrorResponse.Builder(); } /** * Builds instances of {@link org.glowroot.ui.ImmutableInstrumentationErrorResponse ImmutableInstrumentationErrorResponse}. * 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 ImmutableList.Builder errorsBuilder = ImmutableList.builder(); private Builder() {} /** * Fill builder with attribute values from provided {@link InstrumentationConfigJsonService.InstrumentationErrorResponse} 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.InstrumentationErrorResponse instance) { Preconditions.checkNotNull(instance); addAllErrors(instance.errors()); return this; } /** * Adds one element to {@link InstrumentationConfigJsonService.InstrumentationErrorResponse#errors() errors} list. * @param element errors element * @return {@code this} builder for chained invocation */ public final Builder addErrors(String element) { errorsBuilder.add(element); return this; } /** * Adds elements to {@link InstrumentationConfigJsonService.InstrumentationErrorResponse#errors() errors} list. * @param elements array of errors elements * @return {@code this} builder for chained invocation */ public final Builder addErrors(String... elements) { errorsBuilder.add(elements); return this; } /** * Sets or replaces all elements for {@link InstrumentationConfigJsonService.InstrumentationErrorResponse#errors() errors} list. * @param elements iterable of errors elements * @return {@code this} builder for chained invocation */ public final Builder errors(Iterable elements) { errorsBuilder = ImmutableList.builder(); return addAllErrors(elements); } /** * Adds elements to {@link InstrumentationConfigJsonService.InstrumentationErrorResponse#errors() errors} list. * @param elements iterable of errors elements * @return {@code this} builder for chained invocation */ public final Builder addAllErrors(Iterable elements) { errorsBuilder.addAll(elements); return this; } /** * Builds new {@link org.glowroot.ui.ImmutableInstrumentationErrorResponse ImmutableInstrumentationErrorResponse}. * @return immutable instance of InstrumentationErrorResponse * @throws exception {@code java.lang.IllegalStateException} if any required attributes are missing */ public ImmutableInstrumentationErrorResponse build() throws IllegalStateException { return new ImmutableInstrumentationErrorResponse(errorsBuilder.build()); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy