
org.glowroot.agent.weaving.ImmutableAnalyzedMethod Maven / Gradle / Ivy
Show all versions of glowroot-agent-it-harness Show documentation
package org.glowroot.agent.weaving;
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.Objects;
import org.glowroot.agent.shaded.google.common.base.Preconditions;
import org.glowroot.agent.shaded.google.common.collect.ImmutableList;
import org.glowroot.agent.shaded.google.common.collect.Lists;
import java.util.List;
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 AnalyzedMethod}.
*
* Use the builder to create immutable instances:
* {@code ImmutableAnalyzedMethod.builder()}.
*/
@SuppressWarnings("all")
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "AnalyzedMethod"})
@Immutable
final class ImmutableAnalyzedMethod extends AnalyzedMethod {
private final String name;
private final ImmutableList parameterTypes;
private final String returnType;
private final int modifiers;
private final @Nullable String signature;
private final ImmutableList exceptions;
private final ImmutableList advisors;
private final ImmutableList declaredOnlyAdvisors;
private ImmutableAnalyzedMethod(
String name,
ImmutableList parameterTypes,
String returnType,
int modifiers,
@Nullable String signature,
ImmutableList exceptions,
ImmutableList advisors,
ImmutableList declaredOnlyAdvisors) {
this.name = name;
this.parameterTypes = parameterTypes;
this.returnType = returnType;
this.modifiers = modifiers;
this.signature = signature;
this.exceptions = exceptions;
this.advisors = advisors;
this.declaredOnlyAdvisors = declaredOnlyAdvisors;
}
/**
* @return The value of the {@code name} attribute
*/
@JsonProperty
@Override
String name() {
return name;
}
/**
* @return The value of the {@code parameterTypes} attribute
*/
@JsonProperty
@Override
ImmutableList parameterTypes() {
return parameterTypes;
}
/**
* @return The value of the {@code returnType} attribute
*/
@JsonProperty
@Override
String returnType() {
return returnType;
}
/**
* @return The value of the {@code modifiers} attribute
*/
@JsonProperty
@Override
int modifiers() {
return modifiers;
}
/**
* @return The value of the {@code signature} attribute
*/
@JsonProperty
@Override
@Nullable String signature() {
return signature;
}
/**
* @return The value of the {@code exceptions} attribute
*/
@JsonProperty
@Override
ImmutableList exceptions() {
return exceptions;
}
/**
* @return The value of the {@code advisors} attribute
*/
@JsonProperty
@Override
ImmutableList advisors() {
return advisors;
}
/**
* @return The value of the {@code declaredOnlyAdvisors} attribute
*/
@JsonProperty
@Override
ImmutableList declaredOnlyAdvisors() {
return declaredOnlyAdvisors;
}
/**
* Copy the current immutable object by setting a value for the {@link AnalyzedMethod#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 ImmutableAnalyzedMethod withName(String value) {
if (this.name.equals(value)) return this;
return new ImmutableAnalyzedMethod(
Preconditions.checkNotNull(value, "name"),
this.parameterTypes,
this.returnType,
this.modifiers,
this.signature,
this.exceptions,
this.advisors,
this.declaredOnlyAdvisors);
}
/**
* Copy the current immutable object with elements that replace the content of {@link AnalyzedMethod#parameterTypes() parameterTypes}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAnalyzedMethod withParameterTypes(String... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAnalyzedMethod(
this.name,
newValue,
this.returnType,
this.modifiers,
this.signature,
this.exceptions,
this.advisors,
this.declaredOnlyAdvisors);
}
/**
* Copy the current immutable object with elements that replace the content of {@link AnalyzedMethod#parameterTypes() parameterTypes}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of parameterTypes elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAnalyzedMethod withParameterTypes(Iterable elements) {
if (this.parameterTypes == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAnalyzedMethod(
this.name,
newValue,
this.returnType,
this.modifiers,
this.signature,
this.exceptions,
this.advisors,
this.declaredOnlyAdvisors);
}
/**
* Copy the current immutable object by setting a value for the {@link AnalyzedMethod#returnType() returnType} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for returnType
* @return A modified copy of the {@code this} object
*/
public final ImmutableAnalyzedMethod withReturnType(String value) {
if (this.returnType.equals(value)) return this;
return new ImmutableAnalyzedMethod(
this.name,
this.parameterTypes,
Preconditions.checkNotNull(value, "returnType"),
this.modifiers,
this.signature,
this.exceptions,
this.advisors,
this.declaredOnlyAdvisors);
}
/**
* Copy the current immutable object by setting a value for the {@link AnalyzedMethod#modifiers() modifiers} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for modifiers
* @return A modified copy of the {@code this} object
*/
public final ImmutableAnalyzedMethod withModifiers(int value) {
if (this.modifiers == value) return this;
return new ImmutableAnalyzedMethod(
this.name,
this.parameterTypes,
this.returnType,
value,
this.signature,
this.exceptions,
this.advisors,
this.declaredOnlyAdvisors);
}
/**
* Copy the current immutable object by setting a value for the {@link AnalyzedMethod#signature() signature} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for signature (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableAnalyzedMethod withSignature(@Nullable String value) {
if (Objects.equal(this.signature, value)) return this;
return new ImmutableAnalyzedMethod(
this.name,
this.parameterTypes,
this.returnType,
this.modifiers,
value,
this.exceptions,
this.advisors,
this.declaredOnlyAdvisors);
}
/**
* Copy the current immutable object with elements that replace the content of {@link AnalyzedMethod#exceptions() exceptions}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAnalyzedMethod withExceptions(String... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAnalyzedMethod(
this.name,
this.parameterTypes,
this.returnType,
this.modifiers,
this.signature,
newValue,
this.advisors,
this.declaredOnlyAdvisors);
}
/**
* Copy the current immutable object with elements that replace the content of {@link AnalyzedMethod#exceptions() exceptions}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of exceptions elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAnalyzedMethod withExceptions(Iterable elements) {
if (this.exceptions == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAnalyzedMethod(
this.name,
this.parameterTypes,
this.returnType,
this.modifiers,
this.signature,
newValue,
this.advisors,
this.declaredOnlyAdvisors);
}
/**
* Copy the current immutable object with elements that replace the content of {@link AnalyzedMethod#advisors() advisors}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAnalyzedMethod withAdvisors(Advice... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAnalyzedMethod(
this.name,
this.parameterTypes,
this.returnType,
this.modifiers,
this.signature,
this.exceptions,
newValue,
this.declaredOnlyAdvisors);
}
/**
* Copy the current immutable object with elements that replace the content of {@link AnalyzedMethod#advisors() advisors}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of advisors elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAnalyzedMethod withAdvisors(Iterable extends Advice> elements) {
if (this.advisors == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAnalyzedMethod(
this.name,
this.parameterTypes,
this.returnType,
this.modifiers,
this.signature,
this.exceptions,
newValue,
this.declaredOnlyAdvisors);
}
/**
* Copy the current immutable object with elements that replace the content of {@link AnalyzedMethod#declaredOnlyAdvisors() declaredOnlyAdvisors}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAnalyzedMethod withDeclaredOnlyAdvisors(Advice... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAnalyzedMethod(
this.name,
this.parameterTypes,
this.returnType,
this.modifiers,
this.signature,
this.exceptions,
this.advisors,
newValue);
}
/**
* Copy the current immutable object with elements that replace the content of {@link AnalyzedMethod#declaredOnlyAdvisors() declaredOnlyAdvisors}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of declaredOnlyAdvisors elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAnalyzedMethod withDeclaredOnlyAdvisors(Iterable extends Advice> elements) {
if (this.declaredOnlyAdvisors == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAnalyzedMethod(
this.name,
this.parameterTypes,
this.returnType,
this.modifiers,
this.signature,
this.exceptions,
this.advisors,
newValue);
}
/**
* This instance is equal to all instances of {@code ImmutableAnalyzedMethod} that have 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 ImmutableAnalyzedMethod
&& equalTo((ImmutableAnalyzedMethod) another);
}
private boolean equalTo(ImmutableAnalyzedMethod another) {
return name.equals(another.name)
&& parameterTypes.equals(another.parameterTypes)
&& returnType.equals(another.returnType)
&& modifiers == another.modifiers
&& Objects.equal(signature, another.signature)
&& exceptions.equals(another.exceptions)
&& advisors.equals(another.advisors)
&& declaredOnlyAdvisors.equals(another.declaredOnlyAdvisors);
}
/**
* Computes a hash code from attributes: {@code name}, {@code parameterTypes}, {@code returnType}, {@code modifiers}, {@code signature}, {@code exceptions}, {@code advisors}, {@code declaredOnlyAdvisors}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 31;
h = h * 17 + name.hashCode();
h = h * 17 + parameterTypes.hashCode();
h = h * 17 + returnType.hashCode();
h = h * 17 + modifiers;
h = h * 17 + Objects.hashCode(signature);
h = h * 17 + exceptions.hashCode();
h = h * 17 + advisors.hashCode();
h = h * 17 + declaredOnlyAdvisors.hashCode();
return h;
}
/**
* Prints the immutable value {@code AnalyzedMethod...} with all non-generated
* and non-auxiliary attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("AnalyzedMethod")
.add("name", name)
.add("parameterTypes", parameterTypes)
.add("returnType", returnType)
.add("modifiers", modifiers)
.add("signature", signature)
.add("exceptions", exceptions)
.add("advisors", advisors)
.add("declaredOnlyAdvisors", declaredOnlyAdvisors)
.toString();
}
/**
* Utility type used to correctly read immutable object from JSON representation.
* @deprecated Do not use this type directly, it exists only for the Jackson-binding infrastructure
*/
@Deprecated
static final class Json extends AnalyzedMethod {
@Nullable String name;
ImmutableList parameterTypes = ImmutableList.of();
@Nullable String returnType;
@Nullable Integer modifiers;
@Nullable String signature;
ImmutableList exceptions = ImmutableList.of();
ImmutableList advisors = ImmutableList.of();
ImmutableList declaredOnlyAdvisors = ImmutableList.of();
@JsonProperty
public void setName(String name) {
this.name = name;
}
@JsonProperty
public void setParameterTypes(ImmutableList parameterTypes) {
this.parameterTypes = parameterTypes;
}
@JsonProperty
public void setReturnType(String returnType) {
this.returnType = returnType;
}
@JsonProperty
public void setModifiers(int modifiers) {
this.modifiers = modifiers;
}
@JsonProperty
public void setSignature(@Nullable String signature) {
this.signature = signature;
}
@JsonProperty
public void setExceptions(ImmutableList exceptions) {
this.exceptions = exceptions;
}
@JsonProperty
public void setAdvisors(ImmutableList advisors) {
this.advisors = advisors;
}
@JsonProperty
public void setDeclaredOnlyAdvisors(ImmutableList declaredOnlyAdvisors) {
this.declaredOnlyAdvisors = declaredOnlyAdvisors;
}
@Override
String name() { throw new UnsupportedOperationException(); }
@Override
ImmutableList parameterTypes() { throw new UnsupportedOperationException(); }
@Override
String returnType() { throw new UnsupportedOperationException(); }
@Override
int modifiers() { throw new UnsupportedOperationException(); }
@Override
String signature() { throw new UnsupportedOperationException(); }
@Override
ImmutableList exceptions() { throw new UnsupportedOperationException(); }
@Override
ImmutableList advisors() { throw new UnsupportedOperationException(); }
@Override
ImmutableList declaredOnlyAdvisors() { throw new UnsupportedOperationException(); }
}
/**
* @param json A JSON-bindable data structure
* @return An immutable value type
* @deprecated Do not use this method directly, it exists only for the Jackson-binding infrastructure
*/
@Deprecated
@JsonCreator
static ImmutableAnalyzedMethod fromJson(Json json) {
ImmutableAnalyzedMethod.Builder builder = ImmutableAnalyzedMethod.builder();
if (json.name != null) {
builder.name(json.name);
}
if (json.parameterTypes != null) {
builder.addAllParameterTypes(json.parameterTypes);
}
if (json.returnType != null) {
builder.returnType(json.returnType);
}
if (json.modifiers != null) {
builder.modifiers(json.modifiers);
}
if (json.signature != null) {
builder.signature(json.signature);
}
if (json.exceptions != null) {
builder.addAllExceptions(json.exceptions);
}
if (json.advisors != null) {
builder.addAllAdvisors(json.advisors);
}
if (json.declaredOnlyAdvisors != null) {
builder.addAllDeclaredOnlyAdvisors(json.declaredOnlyAdvisors);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link AnalyzedMethod} 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 AnalyzedMethod instance
*/
public static ImmutableAnalyzedMethod copyOf(AnalyzedMethod instance) {
if (instance instanceof ImmutableAnalyzedMethod) {
return (ImmutableAnalyzedMethod) instance;
}
return ImmutableAnalyzedMethod.builder()
.copyFrom(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableAnalyzedMethod ImmutableAnalyzedMethod}.
* @return A new ImmutableAnalyzedMethod builder
*/
public static ImmutableAnalyzedMethod.Builder builder() {
return new ImmutableAnalyzedMethod.Builder();
}
/**
* Builds instances of type {@link ImmutableAnalyzedMethod ImmutableAnalyzedMethod}.
* 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.
*/
@NotThreadSafe
static final class Builder {
private static final long INIT_BIT_NAME = 0x1L;
private static final long INIT_BIT_RETURN_TYPE = 0x2L;
private static final long INIT_BIT_MODIFIERS = 0x4L;
private long initBits = 0x7;
private @Nullable String name;
private ImmutableList.Builder parameterTypesBuilder = ImmutableList.builder();
private @Nullable String returnType;
private int modifiers;
private @Nullable String signature;
private ImmutableList.Builder exceptionsBuilder = ImmutableList.builder();
private ImmutableList.Builder advisorsBuilder = ImmutableList.builder();
private ImmutableList.Builder declaredOnlyAdvisorsBuilder = ImmutableList.builder();
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code AnalyzedMethod} 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 copyFrom(AnalyzedMethod instance) {
Preconditions.checkNotNull(instance, "instance");
name(instance.name());
addAllParameterTypes(instance.parameterTypes());
returnType(instance.returnType());
modifiers(instance.modifiers());
@Nullable String signatureValue = instance.signature();
if (signatureValue != null) {
signature(signatureValue);
}
addAllExceptions(instance.exceptions());
addAllAdvisors(instance.advisors());
addAllDeclaredOnlyAdvisors(instance.declaredOnlyAdvisors());
return this;
}
/**
* Initializes the value for the {@link AnalyzedMethod#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;
}
/**
* Adds one element to {@link AnalyzedMethod#parameterTypes() parameterTypes} list.
* @param element A parameterTypes element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addParameterTypes(String element) {
parameterTypesBuilder.add(element);
return this;
}
/**
* Adds elements to {@link AnalyzedMethod#parameterTypes() parameterTypes} list.
* @param elements An array of parameterTypes elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addParameterTypes(String... elements) {
parameterTypesBuilder.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link AnalyzedMethod#parameterTypes() parameterTypes} list.
* @param elements An iterable of parameterTypes elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder parameterTypes(Iterable elements) {
parameterTypesBuilder = ImmutableList.builder();
return addAllParameterTypes(elements);
}
/**
* Adds elements to {@link AnalyzedMethod#parameterTypes() parameterTypes} list.
* @param elements An iterable of parameterTypes elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllParameterTypes(Iterable elements) {
parameterTypesBuilder.addAll(elements);
return this;
}
/**
* Initializes the value for the {@link AnalyzedMethod#returnType() returnType} attribute.
* @param returnType The value for returnType
* @return {@code this} builder for use in a chained invocation
*/
public final Builder returnType(String returnType) {
this.returnType = Preconditions.checkNotNull(returnType, "returnType");
initBits &= ~INIT_BIT_RETURN_TYPE;
return this;
}
/**
* Initializes the value for the {@link AnalyzedMethod#modifiers() modifiers} attribute.
* @param modifiers The value for modifiers
* @return {@code this} builder for use in a chained invocation
*/
public final Builder modifiers(int modifiers) {
this.modifiers = modifiers;
initBits &= ~INIT_BIT_MODIFIERS;
return this;
}
/**
* Initializes the value for the {@link AnalyzedMethod#signature() signature} attribute.
* @param signature The value for signature (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder signature(@Nullable String signature) {
this.signature = signature;
return this;
}
/**
* Adds one element to {@link AnalyzedMethod#exceptions() exceptions} list.
* @param element A exceptions element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addExceptions(String element) {
exceptionsBuilder.add(element);
return this;
}
/**
* Adds elements to {@link AnalyzedMethod#exceptions() exceptions} list.
* @param elements An array of exceptions elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addExceptions(String... elements) {
exceptionsBuilder.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link AnalyzedMethod#exceptions() exceptions} list.
* @param elements An iterable of exceptions elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder exceptions(Iterable elements) {
exceptionsBuilder = ImmutableList.builder();
return addAllExceptions(elements);
}
/**
* Adds elements to {@link AnalyzedMethod#exceptions() exceptions} list.
* @param elements An iterable of exceptions elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllExceptions(Iterable elements) {
exceptionsBuilder.addAll(elements);
return this;
}
/**
* Adds one element to {@link AnalyzedMethod#advisors() advisors} list.
* @param element A advisors element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAdvisors(Advice element) {
advisorsBuilder.add(element);
return this;
}
/**
* Adds elements to {@link AnalyzedMethod#advisors() advisors} list.
* @param elements An array of advisors elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAdvisors(Advice... elements) {
advisorsBuilder.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link AnalyzedMethod#advisors() advisors} list.
* @param elements An iterable of advisors elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder advisors(Iterable extends Advice> elements) {
advisorsBuilder = ImmutableList.builder();
return addAllAdvisors(elements);
}
/**
* Adds elements to {@link AnalyzedMethod#advisors() advisors} list.
* @param elements An iterable of advisors elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllAdvisors(Iterable extends Advice> elements) {
advisorsBuilder.addAll(elements);
return this;
}
/**
* Adds one element to {@link AnalyzedMethod#declaredOnlyAdvisors() declaredOnlyAdvisors} list.
* @param element A declaredOnlyAdvisors element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addDeclaredOnlyAdvisors(Advice element) {
declaredOnlyAdvisorsBuilder.add(element);
return this;
}
/**
* Adds elements to {@link AnalyzedMethod#declaredOnlyAdvisors() declaredOnlyAdvisors} list.
* @param elements An array of declaredOnlyAdvisors elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addDeclaredOnlyAdvisors(Advice... elements) {
declaredOnlyAdvisorsBuilder.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link AnalyzedMethod#declaredOnlyAdvisors() declaredOnlyAdvisors} list.
* @param elements An iterable of declaredOnlyAdvisors elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder declaredOnlyAdvisors(Iterable extends Advice> elements) {
declaredOnlyAdvisorsBuilder = ImmutableList.builder();
return addAllDeclaredOnlyAdvisors(elements);
}
/**
* Adds elements to {@link AnalyzedMethod#declaredOnlyAdvisors() declaredOnlyAdvisors} list.
* @param elements An iterable of declaredOnlyAdvisors elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllDeclaredOnlyAdvisors(Iterable extends Advice> elements) {
declaredOnlyAdvisorsBuilder.addAll(elements);
return this;
}
/**
* Builds a new {@link ImmutableAnalyzedMethod ImmutableAnalyzedMethod}.
* @return An immutable instance of AnalyzedMethod
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableAnalyzedMethod build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableAnalyzedMethod(
name,
parameterTypesBuilder.build(),
returnType,
modifiers,
signature,
exceptionsBuilder.build(),
advisorsBuilder.build(),
declaredOnlyAdvisorsBuilder.build());
}
private String formatRequiredAttributesMessage() {
List attributes = Lists.newArrayList();
if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name");
if ((initBits & INIT_BIT_RETURN_TYPE) != 0) attributes.add("returnType");
if ((initBits & INIT_BIT_MODIFIERS) != 0) attributes.add("modifiers");
return "Cannot build AnalyzedMethod, some of required attributes are not set " + attributes;
}
}
}