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

org.glowroot.instrumentation.test.harness.ImmutableIncomingSpanError Maven / Gradle / Ivy

The newest version!
package org.glowroot.instrumentation.test.harness;

import org.glowroot.instrumentation.test.harness.shaded.com.google.errorprone.annotations.CanIgnoreReturnValue;
import org.glowroot.instrumentation.test.harness.shaded.com.google.errorprone.annotations.Var;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.immutables.value.Generated;

/**
 * Immutable implementation of {@link IncomingSpan.IncomingSpanError}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableIncomingSpanError.builder()}. */ @Generated(from = "IncomingSpan.IncomingSpanError", generator = "Immutables") @SuppressWarnings({"all"}) @javax.annotation.Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableIncomingSpanError implements IncomingSpan.IncomingSpanError { private final @Nullable String message; private final @Nullable ThrowableInfo exception; private ImmutableIncomingSpanError( @Nullable String message, @Nullable ThrowableInfo exception) { this.message = message; this.exception = exception; } /** * @return The value of the {@code message} attribute */ @Override public @Nullable String message() { return message; } /** * @return The value of the {@code exception} attribute */ @Override public @Nullable ThrowableInfo exception() { return exception; } /** * Copy the current immutable object by setting a value for the {@link IncomingSpan.IncomingSpanError#message() message} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for message (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableIncomingSpanError withMessage(@Nullable String value) { if (ImmutableIncomingSpanError.equals(this.message, value)) return this; return new ImmutableIncomingSpanError(value, this.exception); } /** * Copy the current immutable object by setting a value for the {@link IncomingSpan.IncomingSpanError#exception() exception} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for exception (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableIncomingSpanError withException(@Nullable ThrowableInfo value) { if (this.exception == value) return this; return new ImmutableIncomingSpanError(this.message, value); } /** * This instance is equal to all instances of {@code ImmutableIncomingSpanError} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(Object another) { if (this == another) return true; return another instanceof ImmutableIncomingSpanError && equalTo((ImmutableIncomingSpanError) another); } private boolean equalTo(ImmutableIncomingSpanError another) { return ImmutableIncomingSpanError.equals(message, another.message) && ImmutableIncomingSpanError.equals(exception, another.exception); } /** * Computes a hash code from attributes: {@code message}, {@code exception}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + ImmutableIncomingSpanError.hashCode(message); h += (h << 5) + ImmutableIncomingSpanError.hashCode(exception); return h; } /** * Prints the immutable value {@code IncomingSpanError} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "IncomingSpanError{" + "message=" + message + ", exception=" + exception + "}"; } /** * Creates an immutable copy of a {@link IncomingSpan.IncomingSpanError} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable IncomingSpanError instance */ public static ImmutableIncomingSpanError copyOf(IncomingSpan.IncomingSpanError instance) { if (instance instanceof ImmutableIncomingSpanError) { return (ImmutableIncomingSpanError) instance; } return ImmutableIncomingSpanError.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableIncomingSpanError ImmutableIncomingSpanError}. *

   * ImmutableIncomingSpanError.builder()
   *    .message(String | null) // nullable {@link IncomingSpan.IncomingSpanError#message() message}
   *    .exception(org.glowroot.instrumentation.test.harness.ThrowableInfo | null) // nullable {@link IncomingSpan.IncomingSpanError#exception() exception}
   *    .build();
   * 
* @return A new ImmutableIncomingSpanError builder */ public static ImmutableIncomingSpanError.Builder builder() { return new ImmutableIncomingSpanError.Builder(); } /** * Builds instances of type {@link ImmutableIncomingSpanError ImmutableIncomingSpanError}. * Initialize attributes and then invoke the {@link #build()} method to create an * immutable instance. *

{@code Builder} is not thread-safe and generally should not be stored in a field or collection, * but instead used immediately to create instances. */ @Generated(from = "IncomingSpan.IncomingSpanError", generator = "Immutables") public static final class Builder { private String message; private ThrowableInfo exception; private Builder() { } /** * Fill a builder with attribute values from the provided {@code IncomingSpanError} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(IncomingSpan.IncomingSpanError instance) { ImmutableIncomingSpanError.requireNonNull(instance, "instance"); @Nullable String messageValue = instance.message(); if (messageValue != null) { message(messageValue); } @Nullable ThrowableInfo exceptionValue = instance.exception(); if (exceptionValue != null) { exception(exceptionValue); } return this; } /** * Initializes the value for the {@link IncomingSpan.IncomingSpanError#message() message} attribute. * @param message The value for message (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder message(@Nullable String message) { this.message = message; return this; } /** * Initializes the value for the {@link IncomingSpan.IncomingSpanError#exception() exception} attribute. * @param exception The value for exception (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder exception(@Nullable ThrowableInfo exception) { this.exception = exception; return this; } /** * Builds a new {@link ImmutableIncomingSpanError ImmutableIncomingSpanError}. * @return An immutable instance of IncomingSpanError * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableIncomingSpanError build() { return new ImmutableIncomingSpanError(message, exception); } } private static T requireNonNull(T object, String message) { if (object == null) throw new NullPointerException(message); return object; } private static int hashCode(Object object) { return object != null ? object.hashCode() : 0; } private static boolean equals(Object left, Object right) { return left == right || (left != null && left.equals(right)); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy