![JAR search and dependency download from the Maven repository](/logo.png)
org.glowroot.instrumentation.engine.weaving.ImmutableInstrumentationDetail Maven / Gradle / Ivy
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.Preconditions;
import org.glowroot.instrumentation.test.harness.shaded.com.google.common.collect.ImmutableList;
import org.immutables.value.Generated;
/**
* Immutable implementation of {@link InstrumentationDetail}.
*
* Use the builder to create immutable instances:
* {@code ImmutableInstrumentationDetail.builder()}.
*/
@Generated(from = "InstrumentationDetail", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
final class ImmutableInstrumentationDetail
implements InstrumentationDetail {
private final ImmutableList pointcutClasses;
private final ImmutableList mixinTypes;
private final ImmutableList shimTypes;
private ImmutableInstrumentationDetail(
ImmutableList pointcutClasses,
ImmutableList mixinTypes,
ImmutableList shimTypes) {
this.pointcutClasses = pointcutClasses;
this.mixinTypes = mixinTypes;
this.shimTypes = shimTypes;
}
/**
* @return The value of the {@code pointcutClasses} attribute
*/
@Override
public ImmutableList pointcutClasses() {
return pointcutClasses;
}
/**
* @return The value of the {@code mixinTypes} attribute
*/
@Override
public ImmutableList mixinTypes() {
return mixinTypes;
}
/**
* @return The value of the {@code shimTypes} attribute
*/
@Override
public ImmutableList shimTypes() {
return shimTypes;
}
/**
* Copy the current immutable object with elements that replace the content of {@link InstrumentationDetail#pointcutClasses() pointcutClasses}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableInstrumentationDetail withPointcutClasses(InstrumentationDetail.PointcutClass... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableInstrumentationDetail(newValue, this.mixinTypes, this.shimTypes);
}
/**
* Copy the current immutable object with elements that replace the content of {@link InstrumentationDetail#pointcutClasses() pointcutClasses}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of pointcutClasses elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableInstrumentationDetail withPointcutClasses(Iterable extends InstrumentationDetail.PointcutClass> elements) {
if (this.pointcutClasses == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableInstrumentationDetail(newValue, this.mixinTypes, this.shimTypes);
}
/**
* Copy the current immutable object with elements that replace the content of {@link InstrumentationDetail#mixinTypes() mixinTypes}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableInstrumentationDetail withMixinTypes(MixinType... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableInstrumentationDetail(this.pointcutClasses, newValue, this.shimTypes);
}
/**
* Copy the current immutable object with elements that replace the content of {@link InstrumentationDetail#mixinTypes() mixinTypes}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of mixinTypes elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableInstrumentationDetail withMixinTypes(Iterable extends MixinType> elements) {
if (this.mixinTypes == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableInstrumentationDetail(this.pointcutClasses, newValue, this.shimTypes);
}
/**
* Copy the current immutable object with elements that replace the content of {@link InstrumentationDetail#shimTypes() shimTypes}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableInstrumentationDetail withShimTypes(ShimType... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableInstrumentationDetail(this.pointcutClasses, this.mixinTypes, newValue);
}
/**
* Copy the current immutable object with elements that replace the content of {@link InstrumentationDetail#shimTypes() shimTypes}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of shimTypes elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableInstrumentationDetail withShimTypes(Iterable extends ShimType> elements) {
if (this.shimTypes == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableInstrumentationDetail(this.pointcutClasses, this.mixinTypes, newValue);
}
/**
* This instance is equal to all instances of {@code ImmutableInstrumentationDetail} 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 ImmutableInstrumentationDetail
&& equalTo((ImmutableInstrumentationDetail) another);
}
private boolean equalTo(ImmutableInstrumentationDetail another) {
return pointcutClasses.equals(another.pointcutClasses)
&& mixinTypes.equals(another.mixinTypes)
&& shimTypes.equals(another.shimTypes);
}
/**
* Computes a hash code from attributes: {@code pointcutClasses}, {@code mixinTypes}, {@code shimTypes}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + pointcutClasses.hashCode();
h += (h << 5) + mixinTypes.hashCode();
h += (h << 5) + shimTypes.hashCode();
return h;
}
/**
* Prints the immutable value {@code InstrumentationDetail} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("InstrumentationDetail")
.omitNullValues()
.add("pointcutClasses", pointcutClasses)
.add("mixinTypes", mixinTypes)
.add("shimTypes", shimTypes)
.toString();
}
/**
* Creates an immutable copy of a {@link InstrumentationDetail} 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 InstrumentationDetail instance
*/
public static ImmutableInstrumentationDetail copyOf(InstrumentationDetail instance) {
if (instance instanceof ImmutableInstrumentationDetail) {
return (ImmutableInstrumentationDetail) instance;
}
return ImmutableInstrumentationDetail.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableInstrumentationDetail ImmutableInstrumentationDetail}.
*
* ImmutableInstrumentationDetail.builder()
* .addPointcutClasses|addAllPointcutClasses(org.glowroot.instrumentation.engine.weaving.InstrumentationDetail.PointcutClass) // {@link InstrumentationDetail#pointcutClasses() pointcutClasses} elements
* .addMixinTypes|addAllMixinTypes(org.glowroot.instrumentation.engine.weaving.MixinType) // {@link InstrumentationDetail#mixinTypes() mixinTypes} elements
* .addShimTypes|addAllShimTypes(org.glowroot.instrumentation.engine.weaving.ShimType) // {@link InstrumentationDetail#shimTypes() shimTypes} elements
* .build();
*
* @return A new ImmutableInstrumentationDetail builder
*/
public static ImmutableInstrumentationDetail.Builder builder() {
return new ImmutableInstrumentationDetail.Builder();
}
/**
* Builds instances of type {@link ImmutableInstrumentationDetail ImmutableInstrumentationDetail}.
* 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 = "InstrumentationDetail", generator = "Immutables")
public static final class Builder {
private ImmutableList.Builder pointcutClasses = ImmutableList.builder();
private ImmutableList.Builder mixinTypes = ImmutableList.builder();
private ImmutableList.Builder shimTypes = ImmutableList.builder();
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code InstrumentationDetail} 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(InstrumentationDetail instance) {
Preconditions.checkNotNull(instance, "instance");
addAllPointcutClasses(instance.pointcutClasses());
addAllMixinTypes(instance.mixinTypes());
addAllShimTypes(instance.shimTypes());
return this;
}
/**
* Adds one element to {@link InstrumentationDetail#pointcutClasses() pointcutClasses} list.
* @param element A pointcutClasses element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addPointcutClasses(InstrumentationDetail.PointcutClass element) {
this.pointcutClasses.add(element);
return this;
}
/**
* Adds elements to {@link InstrumentationDetail#pointcutClasses() pointcutClasses} list.
* @param elements An array of pointcutClasses elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addPointcutClasses(InstrumentationDetail.PointcutClass... elements) {
this.pointcutClasses.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link InstrumentationDetail#pointcutClasses() pointcutClasses} list.
* @param elements An iterable of pointcutClasses elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder pointcutClasses(Iterable extends InstrumentationDetail.PointcutClass> elements) {
this.pointcutClasses = ImmutableList.builder();
return addAllPointcutClasses(elements);
}
/**
* Adds elements to {@link InstrumentationDetail#pointcutClasses() pointcutClasses} list.
* @param elements An iterable of pointcutClasses elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllPointcutClasses(Iterable extends InstrumentationDetail.PointcutClass> elements) {
this.pointcutClasses.addAll(elements);
return this;
}
/**
* Adds one element to {@link InstrumentationDetail#mixinTypes() mixinTypes} list.
* @param element A mixinTypes element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addMixinTypes(MixinType element) {
this.mixinTypes.add(element);
return this;
}
/**
* Adds elements to {@link InstrumentationDetail#mixinTypes() mixinTypes} list.
* @param elements An array of mixinTypes elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addMixinTypes(MixinType... elements) {
this.mixinTypes.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link InstrumentationDetail#mixinTypes() mixinTypes} list.
* @param elements An iterable of mixinTypes elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder mixinTypes(Iterable extends MixinType> elements) {
this.mixinTypes = ImmutableList.builder();
return addAllMixinTypes(elements);
}
/**
* Adds elements to {@link InstrumentationDetail#mixinTypes() mixinTypes} list.
* @param elements An iterable of mixinTypes elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllMixinTypes(Iterable extends MixinType> elements) {
this.mixinTypes.addAll(elements);
return this;
}
/**
* Adds one element to {@link InstrumentationDetail#shimTypes() shimTypes} list.
* @param element A shimTypes element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addShimTypes(ShimType element) {
this.shimTypes.add(element);
return this;
}
/**
* Adds elements to {@link InstrumentationDetail#shimTypes() shimTypes} list.
* @param elements An array of shimTypes elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addShimTypes(ShimType... elements) {
this.shimTypes.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link InstrumentationDetail#shimTypes() shimTypes} list.
* @param elements An iterable of shimTypes elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder shimTypes(Iterable extends ShimType> elements) {
this.shimTypes = ImmutableList.builder();
return addAllShimTypes(elements);
}
/**
* Adds elements to {@link InstrumentationDetail#shimTypes() shimTypes} list.
* @param elements An iterable of shimTypes elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllShimTypes(Iterable extends ShimType> elements) {
this.shimTypes.addAll(elements);
return this;
}
/**
* Builds a new {@link ImmutableInstrumentationDetail ImmutableInstrumentationDetail}.
* @return An immutable instance of InstrumentationDetail
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableInstrumentationDetail build() {
return new ImmutableInstrumentationDetail(pointcutClasses.build(), mixinTypes.build(), shimTypes.build());
}
}
}