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

org.glowroot.instrumentation.engine.weaving.ImmutableAnalyzedClassAndLoader Maven / Gradle / Ivy

The newest version!
package org.glowroot.instrumentation.engine.weaving;

import org.glowroot.instrumentation.test.harness.shaded.com.google.common.base.MoreObjects;
import org.glowroot.instrumentation.test.harness.shaded.com.google.common.base.Objects;
import org.glowroot.instrumentation.test.harness.shaded.com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.immutables.value.Generated;

/**
 * Immutable implementation of {@link AnalyzedWorld.AnalyzedClassAndLoader}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableAnalyzedClassAndLoader.builder()}. */ @Generated(from = "AnalyzedWorld.AnalyzedClassAndLoader", generator = "Immutables") @SuppressWarnings({"all"}) @javax.annotation.Generated("org.immutables.processor.ProxyProcessor") final class ImmutableAnalyzedClassAndLoader implements AnalyzedWorld.AnalyzedClassAndLoader { private final AnalyzedClass analyzedClass; private final @Nullable ClassLoader analyzedClassLoader; private ImmutableAnalyzedClassAndLoader( AnalyzedClass analyzedClass, @Nullable ClassLoader analyzedClassLoader) { this.analyzedClass = analyzedClass; this.analyzedClassLoader = analyzedClassLoader; } /** * @return The value of the {@code analyzedClass} attribute */ @Override public AnalyzedClass analyzedClass() { return analyzedClass; } /** * @return The value of the {@code analyzedClassLoader} attribute */ @Override public @Nullable ClassLoader analyzedClassLoader() { return analyzedClassLoader; } /** * Copy the current immutable object by setting a value for the {@link AnalyzedWorld.AnalyzedClassAndLoader#analyzedClass() analyzedClass} 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 analyzedClass * @return A modified copy of the {@code this} object */ public final ImmutableAnalyzedClassAndLoader withAnalyzedClass(AnalyzedClass value) { if (this.analyzedClass == value) return this; AnalyzedClass newValue = Preconditions.checkNotNull(value, "analyzedClass"); return new ImmutableAnalyzedClassAndLoader(newValue, this.analyzedClassLoader); } /** * Copy the current immutable object by setting a value for the {@link AnalyzedWorld.AnalyzedClassAndLoader#analyzedClassLoader() analyzedClassLoader} 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 analyzedClassLoader (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableAnalyzedClassAndLoader withAnalyzedClassLoader(@Nullable ClassLoader value) { if (this.analyzedClassLoader == value) return this; return new ImmutableAnalyzedClassAndLoader(this.analyzedClass, value); } /** * This instance is equal to all instances of {@code ImmutableAnalyzedClassAndLoader} 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 ImmutableAnalyzedClassAndLoader && equalTo((ImmutableAnalyzedClassAndLoader) another); } private boolean equalTo(ImmutableAnalyzedClassAndLoader another) { return analyzedClass.equals(another.analyzedClass) && Objects.equal(analyzedClassLoader, another.analyzedClassLoader); } /** * Computes a hash code from attributes: {@code analyzedClass}, {@code analyzedClassLoader}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + analyzedClass.hashCode(); h += (h << 5) + Objects.hashCode(analyzedClassLoader); return h; } /** * Prints the immutable value {@code AnalyzedClassAndLoader} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("AnalyzedClassAndLoader") .omitNullValues() .add("analyzedClass", analyzedClass) .add("analyzedClassLoader", analyzedClassLoader) .toString(); } /** * Creates an immutable copy of a {@link AnalyzedWorld.AnalyzedClassAndLoader} 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 AnalyzedClassAndLoader instance */ public static ImmutableAnalyzedClassAndLoader copyOf(AnalyzedWorld.AnalyzedClassAndLoader instance) { if (instance instanceof ImmutableAnalyzedClassAndLoader) { return (ImmutableAnalyzedClassAndLoader) instance; } return ImmutableAnalyzedClassAndLoader.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableAnalyzedClassAndLoader ImmutableAnalyzedClassAndLoader}. *

   * ImmutableAnalyzedClassAndLoader.builder()
   *    .analyzedClass(org.glowroot.instrumentation.engine.weaving.AnalyzedClass) // required {@link AnalyzedWorld.AnalyzedClassAndLoader#analyzedClass() analyzedClass}
   *    .analyzedClassLoader(ClassLoader | null) // nullable {@link AnalyzedWorld.AnalyzedClassAndLoader#analyzedClassLoader() analyzedClassLoader}
   *    .build();
   * 
* @return A new ImmutableAnalyzedClassAndLoader builder */ public static ImmutableAnalyzedClassAndLoader.Builder builder() { return new ImmutableAnalyzedClassAndLoader.Builder(); } /** * Builds instances of type {@link ImmutableAnalyzedClassAndLoader ImmutableAnalyzedClassAndLoader}. * 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 = "AnalyzedWorld.AnalyzedClassAndLoader", generator = "Immutables") public static final class Builder { private static final long INIT_BIT_ANALYZED_CLASS = 0x1L; private long initBits = 0x1L; private AnalyzedClass analyzedClass; private ClassLoader analyzedClassLoader; private Builder() { } /** * Fill a builder with attribute values from the provided {@code AnalyzedClassAndLoader} 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 */ public final Builder from(AnalyzedWorld.AnalyzedClassAndLoader instance) { Preconditions.checkNotNull(instance, "instance"); analyzedClass(instance.analyzedClass()); @Nullable ClassLoader analyzedClassLoaderValue = instance.analyzedClassLoader(); if (analyzedClassLoaderValue != null) { analyzedClassLoader(analyzedClassLoaderValue); } return this; } /** * Initializes the value for the {@link AnalyzedWorld.AnalyzedClassAndLoader#analyzedClass() analyzedClass} attribute. * @param analyzedClass The value for analyzedClass * @return {@code this} builder for use in a chained invocation */ public final Builder analyzedClass(AnalyzedClass analyzedClass) { this.analyzedClass = Preconditions.checkNotNull(analyzedClass, "analyzedClass"); initBits &= ~INIT_BIT_ANALYZED_CLASS; return this; } /** * Initializes the value for the {@link AnalyzedWorld.AnalyzedClassAndLoader#analyzedClassLoader() analyzedClassLoader} attribute. * @param analyzedClassLoader The value for analyzedClassLoader (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder analyzedClassLoader(@Nullable ClassLoader analyzedClassLoader) { this.analyzedClassLoader = analyzedClassLoader; return this; } /** * Builds a new {@link ImmutableAnalyzedClassAndLoader ImmutableAnalyzedClassAndLoader}. * @return An immutable instance of AnalyzedClassAndLoader * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableAnalyzedClassAndLoader build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableAnalyzedClassAndLoader(analyzedClass, analyzedClassLoader); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList(); if ((initBits & INIT_BIT_ANALYZED_CLASS) != 0) attributes.add("analyzedClass"); return "Cannot build AnalyzedClassAndLoader, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy