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

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

There is a newer version: 0.14.9
Show 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 org.glowroot.instrumentation.test.harness.shaded.com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.immutables.value.Generated;
import org.glowroot.instrumentation.test.harness.shaded.org.objectweb.asm.Type;

/**
 * Immutable implementation of {@link ThinClassVisitor.ThinClass}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableThinClass.builder()}. */ @Generated(from = "ThinClassVisitor.ThinClass", generator = "Immutables") @SuppressWarnings({"all"}) @javax.annotation.Generated("org.immutables.processor.ProxyProcessor") final class ImmutableThinClass implements ThinClassVisitor.ThinClass { private final int access; private final String name; private final @Nullable String superName; private final ImmutableList interfaces; private final ImmutableList annotations; private final ImmutableList nonBridgeMethods; private final ImmutableList bridgeMethods; private final ImmutableList ejbRemoteInterfaces; private ImmutableThinClass( int access, String name, @Nullable String superName, ImmutableList interfaces, ImmutableList annotations, ImmutableList nonBridgeMethods, ImmutableList bridgeMethods, ImmutableList ejbRemoteInterfaces) { this.access = access; this.name = name; this.superName = superName; this.interfaces = interfaces; this.annotations = annotations; this.nonBridgeMethods = nonBridgeMethods; this.bridgeMethods = bridgeMethods; this.ejbRemoteInterfaces = ejbRemoteInterfaces; } /** * @return The value of the {@code access} attribute */ @Override public int access() { return access; } /** * @return The value of the {@code name} attribute */ @Override public String name() { return name; } /** * @return The value of the {@code superName} attribute */ @Override public @Nullable String superName() { return superName; } /** * @return The value of the {@code interfaces} attribute */ @Override public ImmutableList interfaces() { return interfaces; } /** * @return The value of the {@code annotations} attribute */ @Override public ImmutableList annotations() { return annotations; } /** * @return The value of the {@code nonBridgeMethods} attribute */ @Override public ImmutableList nonBridgeMethods() { return nonBridgeMethods; } /** * @return The value of the {@code bridgeMethods} attribute */ @Override public ImmutableList bridgeMethods() { return bridgeMethods; } /** * @return The value of the {@code ejbRemoteInterfaces} attribute */ @Override public ImmutableList ejbRemoteInterfaces() { return ejbRemoteInterfaces; } /** * Copy the current immutable object by setting a value for the {@link ThinClassVisitor.ThinClass#access() access} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for access * @return A modified copy of the {@code this} object */ public final ImmutableThinClass withAccess(int value) { if (this.access == value) return this; return new ImmutableThinClass( value, this.name, this.superName, this.interfaces, this.annotations, this.nonBridgeMethods, this.bridgeMethods, this.ejbRemoteInterfaces); } /** * Copy the current immutable object by setting a value for the {@link ThinClassVisitor.ThinClass#name() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final ImmutableThinClass withName(String value) { String newValue = Preconditions.checkNotNull(value, "name"); if (this.name.equals(newValue)) return this; return new ImmutableThinClass( this.access, newValue, this.superName, this.interfaces, this.annotations, this.nonBridgeMethods, this.bridgeMethods, this.ejbRemoteInterfaces); } /** * Copy the current immutable object by setting a value for the {@link ThinClassVisitor.ThinClass#superName() superName} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for superName (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableThinClass withSuperName(@Nullable String value) { if (Objects.equal(this.superName, value)) return this; return new ImmutableThinClass( this.access, this.name, value, this.interfaces, this.annotations, this.nonBridgeMethods, this.bridgeMethods, this.ejbRemoteInterfaces); } /** * Copy the current immutable object with elements that replace the content of {@link ThinClassVisitor.ThinClass#interfaces() interfaces}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableThinClass withInterfaces(String... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableThinClass( this.access, this.name, this.superName, newValue, this.annotations, this.nonBridgeMethods, this.bridgeMethods, this.ejbRemoteInterfaces); } /** * Copy the current immutable object with elements that replace the content of {@link ThinClassVisitor.ThinClass#interfaces() interfaces}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of interfaces elements to set * @return A modified copy of {@code this} object */ public final ImmutableThinClass withInterfaces(Iterable elements) { if (this.interfaces == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableThinClass( this.access, this.name, this.superName, newValue, this.annotations, this.nonBridgeMethods, this.bridgeMethods, this.ejbRemoteInterfaces); } /** * Copy the current immutable object with elements that replace the content of {@link ThinClassVisitor.ThinClass#annotations() annotations}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableThinClass withAnnotations(String... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableThinClass( this.access, this.name, this.superName, this.interfaces, newValue, this.nonBridgeMethods, this.bridgeMethods, this.ejbRemoteInterfaces); } /** * Copy the current immutable object with elements that replace the content of {@link ThinClassVisitor.ThinClass#annotations() annotations}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of annotations elements to set * @return A modified copy of {@code this} object */ public final ImmutableThinClass withAnnotations(Iterable elements) { if (this.annotations == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableThinClass( this.access, this.name, this.superName, this.interfaces, newValue, this.nonBridgeMethods, this.bridgeMethods, this.ejbRemoteInterfaces); } /** * Copy the current immutable object with elements that replace the content of {@link ThinClassVisitor.ThinClass#nonBridgeMethods() nonBridgeMethods}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableThinClass withNonBridgeMethods(ThinClassVisitor.ThinMethod... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableThinClass( this.access, this.name, this.superName, this.interfaces, this.annotations, newValue, this.bridgeMethods, this.ejbRemoteInterfaces); } /** * Copy the current immutable object with elements that replace the content of {@link ThinClassVisitor.ThinClass#nonBridgeMethods() nonBridgeMethods}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of nonBridgeMethods elements to set * @return A modified copy of {@code this} object */ public final ImmutableThinClass withNonBridgeMethods(Iterable elements) { if (this.nonBridgeMethods == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableThinClass( this.access, this.name, this.superName, this.interfaces, this.annotations, newValue, this.bridgeMethods, this.ejbRemoteInterfaces); } /** * Copy the current immutable object with elements that replace the content of {@link ThinClassVisitor.ThinClass#bridgeMethods() bridgeMethods}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableThinClass withBridgeMethods(ThinClassVisitor.ThinMethod... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableThinClass( this.access, this.name, this.superName, this.interfaces, this.annotations, this.nonBridgeMethods, newValue, this.ejbRemoteInterfaces); } /** * Copy the current immutable object with elements that replace the content of {@link ThinClassVisitor.ThinClass#bridgeMethods() bridgeMethods}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of bridgeMethods elements to set * @return A modified copy of {@code this} object */ public final ImmutableThinClass withBridgeMethods(Iterable elements) { if (this.bridgeMethods == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableThinClass( this.access, this.name, this.superName, this.interfaces, this.annotations, this.nonBridgeMethods, newValue, this.ejbRemoteInterfaces); } /** * Copy the current immutable object with elements that replace the content of {@link ThinClassVisitor.ThinClass#ejbRemoteInterfaces() ejbRemoteInterfaces}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableThinClass withEjbRemoteInterfaces(Type... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableThinClass( this.access, this.name, this.superName, this.interfaces, this.annotations, this.nonBridgeMethods, this.bridgeMethods, newValue); } /** * Copy the current immutable object with elements that replace the content of {@link ThinClassVisitor.ThinClass#ejbRemoteInterfaces() ejbRemoteInterfaces}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of ejbRemoteInterfaces elements to set * @return A modified copy of {@code this} object */ public final ImmutableThinClass withEjbRemoteInterfaces(Iterable elements) { if (this.ejbRemoteInterfaces == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableThinClass( this.access, this.name, this.superName, this.interfaces, this.annotations, this.nonBridgeMethods, this.bridgeMethods, newValue); } /** * This instance is equal to all instances of {@code ImmutableThinClass} 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 ImmutableThinClass && equalTo((ImmutableThinClass) another); } private boolean equalTo(ImmutableThinClass another) { return access == another.access && name.equals(another.name) && Objects.equal(superName, another.superName) && interfaces.equals(another.interfaces) && annotations.equals(another.annotations) && nonBridgeMethods.equals(another.nonBridgeMethods) && bridgeMethods.equals(another.bridgeMethods) && ejbRemoteInterfaces.equals(another.ejbRemoteInterfaces); } /** * Computes a hash code from attributes: {@code access}, {@code name}, {@code superName}, {@code interfaces}, {@code annotations}, {@code nonBridgeMethods}, {@code bridgeMethods}, {@code ejbRemoteInterfaces}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + access; h += (h << 5) + name.hashCode(); h += (h << 5) + Objects.hashCode(superName); h += (h << 5) + interfaces.hashCode(); h += (h << 5) + annotations.hashCode(); h += (h << 5) + nonBridgeMethods.hashCode(); h += (h << 5) + bridgeMethods.hashCode(); h += (h << 5) + ejbRemoteInterfaces.hashCode(); return h; } /** * Prints the immutable value {@code ThinClass} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("ThinClass") .omitNullValues() .add("access", access) .add("name", name) .add("superName", superName) .add("interfaces", interfaces) .add("annotations", annotations) .add("nonBridgeMethods", nonBridgeMethods) .add("bridgeMethods", bridgeMethods) .add("ejbRemoteInterfaces", ejbRemoteInterfaces) .toString(); } /** * Creates an immutable copy of a {@link ThinClassVisitor.ThinClass} 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 ThinClass instance */ public static ImmutableThinClass copyOf(ThinClassVisitor.ThinClass instance) { if (instance instanceof ImmutableThinClass) { return (ImmutableThinClass) instance; } return ImmutableThinClass.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableThinClass ImmutableThinClass}. *

   * ImmutableThinClass.builder()
   *    .access(int) // required {@link ThinClassVisitor.ThinClass#access() access}
   *    .name(String) // required {@link ThinClassVisitor.ThinClass#name() name}
   *    .superName(String | null) // nullable {@link ThinClassVisitor.ThinClass#superName() superName}
   *    .addInterfaces|addAllInterfaces(String) // {@link ThinClassVisitor.ThinClass#interfaces() interfaces} elements
   *    .addAnnotations|addAllAnnotations(String) // {@link ThinClassVisitor.ThinClass#annotations() annotations} elements
   *    .addNonBridgeMethods|addAllNonBridgeMethods(org.glowroot.instrumentation.engine.weaving.ThinClassVisitor.ThinMethod) // {@link ThinClassVisitor.ThinClass#nonBridgeMethods() nonBridgeMethods} elements
   *    .addBridgeMethods|addAllBridgeMethods(org.glowroot.instrumentation.engine.weaving.ThinClassVisitor.ThinMethod) // {@link ThinClassVisitor.ThinClass#bridgeMethods() bridgeMethods} elements
   *    .addEjbRemoteInterfaces|addAllEjbRemoteInterfaces(org.glowroot.instrumentation.test.harness.shaded.org.objectweb.asm.Type) // {@link ThinClassVisitor.ThinClass#ejbRemoteInterfaces() ejbRemoteInterfaces} elements
   *    .build();
   * 
* @return A new ImmutableThinClass builder */ public static ImmutableThinClass.Builder builder() { return new ImmutableThinClass.Builder(); } /** * Builds instances of type {@link ImmutableThinClass ImmutableThinClass}. * 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 = "ThinClassVisitor.ThinClass", generator = "Immutables") public static final class Builder { private static final long INIT_BIT_ACCESS = 0x1L; private static final long INIT_BIT_NAME = 0x2L; private long initBits = 0x3L; private int access; private String name; private String superName; private ImmutableList.Builder interfaces = ImmutableList.builder(); private ImmutableList.Builder annotations = ImmutableList.builder(); private ImmutableList.Builder nonBridgeMethods = ImmutableList.builder(); private ImmutableList.Builder bridgeMethods = ImmutableList.builder(); private ImmutableList.Builder ejbRemoteInterfaces = ImmutableList.builder(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code ThinClass} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * Collection elements and entries will be added, not replaced. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ThinClassVisitor.ThinClass instance) { Preconditions.checkNotNull(instance, "instance"); access(instance.access()); name(instance.name()); @Nullable String superNameValue = instance.superName(); if (superNameValue != null) { superName(superNameValue); } addAllInterfaces(instance.interfaces()); addAllAnnotations(instance.annotations()); addAllNonBridgeMethods(instance.nonBridgeMethods()); addAllBridgeMethods(instance.bridgeMethods()); addAllEjbRemoteInterfaces(instance.ejbRemoteInterfaces()); return this; } /** * Initializes the value for the {@link ThinClassVisitor.ThinClass#access() access} attribute. * @param access The value for access * @return {@code this} builder for use in a chained invocation */ public final Builder access(int access) { this.access = access; initBits &= ~INIT_BIT_ACCESS; return this; } /** * Initializes the value for the {@link ThinClassVisitor.ThinClass#name() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ public final Builder name(String name) { this.name = Preconditions.checkNotNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Initializes the value for the {@link ThinClassVisitor.ThinClass#superName() superName} attribute. * @param superName The value for superName (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder superName(@Nullable String superName) { this.superName = superName; return this; } /** * Adds one element to {@link ThinClassVisitor.ThinClass#interfaces() interfaces} list. * @param element A interfaces element * @return {@code this} builder for use in a chained invocation */ public final Builder addInterfaces(String element) { this.interfaces.add(element); return this; } /** * Adds elements to {@link ThinClassVisitor.ThinClass#interfaces() interfaces} list. * @param elements An array of interfaces elements * @return {@code this} builder for use in a chained invocation */ public final Builder addInterfaces(String... elements) { this.interfaces.add(elements); return this; } /** * Sets or replaces all elements for {@link ThinClassVisitor.ThinClass#interfaces() interfaces} list. * @param elements An iterable of interfaces elements * @return {@code this} builder for use in a chained invocation */ public final Builder interfaces(Iterable elements) { this.interfaces = ImmutableList.builder(); return addAllInterfaces(elements); } /** * Adds elements to {@link ThinClassVisitor.ThinClass#interfaces() interfaces} list. * @param elements An iterable of interfaces elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllInterfaces(Iterable elements) { this.interfaces.addAll(elements); return this; } /** * Adds one element to {@link ThinClassVisitor.ThinClass#annotations() annotations} list. * @param element A annotations element * @return {@code this} builder for use in a chained invocation */ public final Builder addAnnotations(String element) { this.annotations.add(element); return this; } /** * Adds elements to {@link ThinClassVisitor.ThinClass#annotations() annotations} list. * @param elements An array of annotations elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAnnotations(String... elements) { this.annotations.add(elements); return this; } /** * Sets or replaces all elements for {@link ThinClassVisitor.ThinClass#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ public final Builder annotations(Iterable elements) { this.annotations = ImmutableList.builder(); return addAllAnnotations(elements); } /** * Adds elements to {@link ThinClassVisitor.ThinClass#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllAnnotations(Iterable elements) { this.annotations.addAll(elements); return this; } /** * Adds one element to {@link ThinClassVisitor.ThinClass#nonBridgeMethods() nonBridgeMethods} list. * @param element A nonBridgeMethods element * @return {@code this} builder for use in a chained invocation */ public final Builder addNonBridgeMethods(ThinClassVisitor.ThinMethod element) { this.nonBridgeMethods.add(element); return this; } /** * Adds elements to {@link ThinClassVisitor.ThinClass#nonBridgeMethods() nonBridgeMethods} list. * @param elements An array of nonBridgeMethods elements * @return {@code this} builder for use in a chained invocation */ public final Builder addNonBridgeMethods(ThinClassVisitor.ThinMethod... elements) { this.nonBridgeMethods.add(elements); return this; } /** * Sets or replaces all elements for {@link ThinClassVisitor.ThinClass#nonBridgeMethods() nonBridgeMethods} list. * @param elements An iterable of nonBridgeMethods elements * @return {@code this} builder for use in a chained invocation */ public final Builder nonBridgeMethods(Iterable elements) { this.nonBridgeMethods = ImmutableList.builder(); return addAllNonBridgeMethods(elements); } /** * Adds elements to {@link ThinClassVisitor.ThinClass#nonBridgeMethods() nonBridgeMethods} list. * @param elements An iterable of nonBridgeMethods elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllNonBridgeMethods(Iterable elements) { this.nonBridgeMethods.addAll(elements); return this; } /** * Adds one element to {@link ThinClassVisitor.ThinClass#bridgeMethods() bridgeMethods} list. * @param element A bridgeMethods element * @return {@code this} builder for use in a chained invocation */ public final Builder addBridgeMethods(ThinClassVisitor.ThinMethod element) { this.bridgeMethods.add(element); return this; } /** * Adds elements to {@link ThinClassVisitor.ThinClass#bridgeMethods() bridgeMethods} list. * @param elements An array of bridgeMethods elements * @return {@code this} builder for use in a chained invocation */ public final Builder addBridgeMethods(ThinClassVisitor.ThinMethod... elements) { this.bridgeMethods.add(elements); return this; } /** * Sets or replaces all elements for {@link ThinClassVisitor.ThinClass#bridgeMethods() bridgeMethods} list. * @param elements An iterable of bridgeMethods elements * @return {@code this} builder for use in a chained invocation */ public final Builder bridgeMethods(Iterable elements) { this.bridgeMethods = ImmutableList.builder(); return addAllBridgeMethods(elements); } /** * Adds elements to {@link ThinClassVisitor.ThinClass#bridgeMethods() bridgeMethods} list. * @param elements An iterable of bridgeMethods elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllBridgeMethods(Iterable elements) { this.bridgeMethods.addAll(elements); return this; } /** * Adds one element to {@link ThinClassVisitor.ThinClass#ejbRemoteInterfaces() ejbRemoteInterfaces} list. * @param element A ejbRemoteInterfaces element * @return {@code this} builder for use in a chained invocation */ public final Builder addEjbRemoteInterfaces(Type element) { this.ejbRemoteInterfaces.add(element); return this; } /** * Adds elements to {@link ThinClassVisitor.ThinClass#ejbRemoteInterfaces() ejbRemoteInterfaces} list. * @param elements An array of ejbRemoteInterfaces elements * @return {@code this} builder for use in a chained invocation */ public final Builder addEjbRemoteInterfaces(Type... elements) { this.ejbRemoteInterfaces.add(elements); return this; } /** * Sets or replaces all elements for {@link ThinClassVisitor.ThinClass#ejbRemoteInterfaces() ejbRemoteInterfaces} list. * @param elements An iterable of ejbRemoteInterfaces elements * @return {@code this} builder for use in a chained invocation */ public final Builder ejbRemoteInterfaces(Iterable elements) { this.ejbRemoteInterfaces = ImmutableList.builder(); return addAllEjbRemoteInterfaces(elements); } /** * Adds elements to {@link ThinClassVisitor.ThinClass#ejbRemoteInterfaces() ejbRemoteInterfaces} list. * @param elements An iterable of ejbRemoteInterfaces elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllEjbRemoteInterfaces(Iterable elements) { this.ejbRemoteInterfaces.addAll(elements); return this; } /** * Builds a new {@link ImmutableThinClass ImmutableThinClass}. * @return An immutable instance of ThinClass * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableThinClass build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableThinClass( access, name, superName, interfaces.build(), annotations.build(), nonBridgeMethods.build(), bridgeMethods.build(), ejbRemoteInterfaces.build()); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList(); if ((initBits & INIT_BIT_ACCESS) != 0) attributes.add("access"); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); return "Cannot build ThinClass, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy