Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.glowroot.agent.weaving.ImmutableAdvice Maven / Gradle / Ivy
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.ImmutableSet;
import org.glowroot.agent.shaded.google.common.collect.Lists;
import org.glowroot.agent.shaded.google.common.primitives.Booleans;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.glowroot.agent.plugin.api.weaving.Pointcut;
import org.glowroot.agent.shaded.objectweb.asm.Type;
import org.glowroot.agent.shaded.objectweb.asm.commons.Method;
/**
* Immutable implementation of {@link Advice}.
*
* Use the builder to create immutable instances:
* {@code ImmutableAdvice.builder()}.
*/
@SuppressWarnings("all")
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "Advice"})
@Immutable
public final class ImmutableAdvice extends Advice {
private final Pointcut pointcut;
private final Type adviceType;
private final String pointcutClassName;
private final @Nullable Pattern pointcutClassNamePattern;
private final @Nullable Pattern pointcutClassNameAnnotationPattern;
private final String pointcutMethodDeclaringClassName;
private final @Nullable Pattern pointcutMethodDeclaringClassNamePattern;
private final @Nullable Pattern pointcutMethodNamePattern;
private final @Nullable Pattern pointcutMethodAnnotationPattern;
private final ImmutableList pointcutMethodParameterTypes;
private final @Nullable Type travelerType;
private final @Nullable Method isEnabledAdvice;
private final @Nullable Method onBeforeAdvice;
private final @Nullable Method onReturnAdvice;
private final @Nullable Method onThrowAdvice;
private final @Nullable Method onAfterAdvice;
private final ImmutableList isEnabledParameters;
private final ImmutableList onBeforeParameters;
private final ImmutableList onReturnParameters;
private final ImmutableList onThrowParameters;
private final ImmutableList onAfterParameters;
private final boolean hasBindThreadContext;
private final boolean hasBindOptionalThreadContext;
private final boolean reweavable;
private final ImmutableSet classMetaTypes;
private final ImmutableSet methodMetaTypes;
private ImmutableAdvice(
Pointcut pointcut,
Type adviceType,
String pointcutClassName,
@Nullable Pattern pointcutClassNamePattern,
@Nullable Pattern pointcutClassNameAnnotationPattern,
String pointcutMethodDeclaringClassName,
@Nullable Pattern pointcutMethodDeclaringClassNamePattern,
@Nullable Pattern pointcutMethodNamePattern,
@Nullable Pattern pointcutMethodAnnotationPattern,
ImmutableList pointcutMethodParameterTypes,
@Nullable Type travelerType,
@Nullable Method isEnabledAdvice,
@Nullable Method onBeforeAdvice,
@Nullable Method onReturnAdvice,
@Nullable Method onThrowAdvice,
@Nullable Method onAfterAdvice,
ImmutableList isEnabledParameters,
ImmutableList onBeforeParameters,
ImmutableList onReturnParameters,
ImmutableList onThrowParameters,
ImmutableList onAfterParameters,
boolean hasBindThreadContext,
boolean hasBindOptionalThreadContext,
boolean reweavable) {
this.pointcut = pointcut;
this.adviceType = adviceType;
this.pointcutClassName = pointcutClassName;
this.pointcutClassNamePattern = pointcutClassNamePattern;
this.pointcutClassNameAnnotationPattern = pointcutClassNameAnnotationPattern;
this.pointcutMethodDeclaringClassName = pointcutMethodDeclaringClassName;
this.pointcutMethodDeclaringClassNamePattern = pointcutMethodDeclaringClassNamePattern;
this.pointcutMethodNamePattern = pointcutMethodNamePattern;
this.pointcutMethodAnnotationPattern = pointcutMethodAnnotationPattern;
this.pointcutMethodParameterTypes = pointcutMethodParameterTypes;
this.travelerType = travelerType;
this.isEnabledAdvice = isEnabledAdvice;
this.onBeforeAdvice = onBeforeAdvice;
this.onReturnAdvice = onReturnAdvice;
this.onThrowAdvice = onThrowAdvice;
this.onAfterAdvice = onAfterAdvice;
this.isEnabledParameters = isEnabledParameters;
this.onBeforeParameters = onBeforeParameters;
this.onReturnParameters = onReturnParameters;
this.onThrowParameters = onThrowParameters;
this.onAfterParameters = onAfterParameters;
this.hasBindThreadContext = hasBindThreadContext;
this.hasBindOptionalThreadContext = hasBindOptionalThreadContext;
this.reweavable = reweavable;
this.classMetaTypes = initShim.classMetaTypes();
this.methodMetaTypes = initShim.methodMetaTypes();
this.initShim = null;
}
private static final int STAGE_INITIALIZING = -1;
private static final int STAGE_UNINITIALIZED = 0;
private static final int STAGE_INITIALIZED = 1;
private volatile InitShim initShim = new InitShim();
private final class InitShim {
private ImmutableSet classMetaTypes;
private byte classMetaTypesStage;
ImmutableSet classMetaTypes() {
if (classMetaTypesStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (classMetaTypesStage == STAGE_UNINITIALIZED) {
classMetaTypesStage = STAGE_INITIALIZING;
this.classMetaTypes = Preconditions.checkNotNull(ImmutableAdvice.super.classMetaTypes(), "classMetaTypes");
classMetaTypesStage = STAGE_INITIALIZED;
}
return classMetaTypes;
}
private ImmutableSet methodMetaTypes;
private byte methodMetaTypesStage;
ImmutableSet methodMetaTypes() {
if (methodMetaTypesStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (methodMetaTypesStage == STAGE_UNINITIALIZED) {
methodMetaTypesStage = STAGE_INITIALIZING;
this.methodMetaTypes = Preconditions.checkNotNull(ImmutableAdvice.super.methodMetaTypes(), "methodMetaTypes");
methodMetaTypesStage = STAGE_INITIALIZED;
}
return methodMetaTypes;
}
private String formatInitCycleMessage() {
ArrayList attributes = Lists.newArrayList();
if (classMetaTypesStage == STAGE_INITIALIZING) attributes.add("classMetaTypes");
if (methodMetaTypesStage == STAGE_INITIALIZING) attributes.add("methodMetaTypes");
return "Cannot build Advice, attribute initializers form cycle" + attributes;
}
}
/**
* @return The value of the {@code pointcut} attribute
*/
@JsonProperty
@Override
Pointcut pointcut() {
return pointcut;
}
/**
* @return The value of the {@code adviceType} attribute
*/
@JsonProperty
@Override
Type adviceType() {
return adviceType;
}
/**
* @return The value of the {@code pointcutClassName} attribute
*/
@JsonProperty
@Override
String pointcutClassName() {
return pointcutClassName;
}
/**
* @return The value of the {@code pointcutClassNamePattern} attribute
*/
@JsonProperty
@Override
@Nullable Pattern pointcutClassNamePattern() {
return pointcutClassNamePattern;
}
/**
* @return The value of the {@code pointcutClassNameAnnotationPattern} attribute
*/
@JsonProperty
@Override
@Nullable Pattern pointcutClassNameAnnotationPattern() {
return pointcutClassNameAnnotationPattern;
}
/**
* @return The value of the {@code pointcutMethodDeclaringClassName} attribute
*/
@JsonProperty
@Override
String pointcutMethodDeclaringClassName() {
return pointcutMethodDeclaringClassName;
}
/**
* @return The value of the {@code pointcutMethodDeclaringClassNamePattern} attribute
*/
@JsonProperty
@Override
@Nullable Pattern pointcutMethodDeclaringClassNamePattern() {
return pointcutMethodDeclaringClassNamePattern;
}
/**
* @return The value of the {@code pointcutMethodNamePattern} attribute
*/
@JsonProperty
@Override
@Nullable Pattern pointcutMethodNamePattern() {
return pointcutMethodNamePattern;
}
/**
* @return The value of the {@code pointcutMethodAnnotationPattern} attribute
*/
@JsonProperty
@Override
@Nullable Pattern pointcutMethodAnnotationPattern() {
return pointcutMethodAnnotationPattern;
}
/**
* @return The value of the {@code pointcutMethodParameterTypes} attribute
*/
@JsonProperty
@Override
ImmutableList pointcutMethodParameterTypes() {
return pointcutMethodParameterTypes;
}
/**
* @return The value of the {@code travelerType} attribute
*/
@JsonProperty
@Override
@Nullable Type travelerType() {
return travelerType;
}
/**
* @return The value of the {@code isEnabledAdvice} attribute
*/
@JsonProperty
@Override
@Nullable Method isEnabledAdvice() {
return isEnabledAdvice;
}
/**
* @return The value of the {@code onBeforeAdvice} attribute
*/
@JsonProperty
@Override
@Nullable Method onBeforeAdvice() {
return onBeforeAdvice;
}
/**
* @return The value of the {@code onReturnAdvice} attribute
*/
@JsonProperty
@Override
@Nullable Method onReturnAdvice() {
return onReturnAdvice;
}
/**
* @return The value of the {@code onThrowAdvice} attribute
*/
@JsonProperty
@Override
@Nullable Method onThrowAdvice() {
return onThrowAdvice;
}
/**
* @return The value of the {@code onAfterAdvice} attribute
*/
@JsonProperty
@Override
@Nullable Method onAfterAdvice() {
return onAfterAdvice;
}
/**
* @return The value of the {@code isEnabledParameters} attribute
*/
@JsonProperty
@Override
ImmutableList isEnabledParameters() {
return isEnabledParameters;
}
/**
* @return The value of the {@code onBeforeParameters} attribute
*/
@JsonProperty
@Override
ImmutableList onBeforeParameters() {
return onBeforeParameters;
}
/**
* @return The value of the {@code onReturnParameters} attribute
*/
@JsonProperty
@Override
ImmutableList onReturnParameters() {
return onReturnParameters;
}
/**
* @return The value of the {@code onThrowParameters} attribute
*/
@JsonProperty
@Override
ImmutableList onThrowParameters() {
return onThrowParameters;
}
/**
* @return The value of the {@code onAfterParameters} attribute
*/
@JsonProperty
@Override
ImmutableList onAfterParameters() {
return onAfterParameters;
}
/**
* @return The value of the {@code hasBindThreadContext} attribute
*/
@JsonProperty
@Override
boolean hasBindThreadContext() {
return hasBindThreadContext;
}
/**
* @return The value of the {@code hasBindOptionalThreadContext} attribute
*/
@JsonProperty
@Override
boolean hasBindOptionalThreadContext() {
return hasBindOptionalThreadContext;
}
/**
* @return The value of the {@code reweavable} attribute
*/
@JsonProperty
@Override
boolean reweavable() {
return reweavable;
}
/**
* @return The computed-at-construction value of the {@code classMetaTypes} attribute
*/
@JsonProperty
@Override
ImmutableSet classMetaTypes() {
return initShim != null
? initShim.classMetaTypes()
: classMetaTypes;
}
/**
* @return The computed-at-construction value of the {@code methodMetaTypes} attribute
*/
@JsonProperty
@Override
ImmutableSet methodMetaTypes() {
return initShim != null
? initShim.methodMetaTypes()
: methodMetaTypes;
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#pointcut() pointcut} 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 pointcut
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withPointcut(Pointcut value) {
if (this.pointcut == value) return this;
return new ImmutableAdvice(
Preconditions.checkNotNull(value, "pointcut"),
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#adviceType() adviceType} 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 adviceType
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withAdviceType(Type value) {
if (this.adviceType == value) return this;
return new ImmutableAdvice(
this.pointcut,
Preconditions.checkNotNull(value, "adviceType"),
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#pointcutClassName() pointcutClassName} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for pointcutClassName
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withPointcutClassName(String value) {
if (this.pointcutClassName.equals(value)) return this;
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
Preconditions.checkNotNull(value, "pointcutClassName"),
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#pointcutClassNamePattern() pointcutClassNamePattern} 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 pointcutClassNamePattern (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withPointcutClassNamePattern(@Nullable Pattern value) {
if (this.pointcutClassNamePattern == value) return this;
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
value,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#pointcutClassNameAnnotationPattern() pointcutClassNameAnnotationPattern} 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 pointcutClassNameAnnotationPattern (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withPointcutClassNameAnnotationPattern(@Nullable Pattern value) {
if (this.pointcutClassNameAnnotationPattern == value) return this;
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
value,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#pointcutMethodDeclaringClassName() pointcutMethodDeclaringClassName} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for pointcutMethodDeclaringClassName
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withPointcutMethodDeclaringClassName(String value) {
if (this.pointcutMethodDeclaringClassName.equals(value)) return this;
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
Preconditions.checkNotNull(value, "pointcutMethodDeclaringClassName"),
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#pointcutMethodDeclaringClassNamePattern() pointcutMethodDeclaringClassNamePattern} 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 pointcutMethodDeclaringClassNamePattern (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withPointcutMethodDeclaringClassNamePattern(@Nullable Pattern value) {
if (this.pointcutMethodDeclaringClassNamePattern == value) return this;
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
value,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#pointcutMethodNamePattern() pointcutMethodNamePattern} 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 pointcutMethodNamePattern (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withPointcutMethodNamePattern(@Nullable Pattern value) {
if (this.pointcutMethodNamePattern == value) return this;
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
value,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#pointcutMethodAnnotationPattern() pointcutMethodAnnotationPattern} 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 pointcutMethodAnnotationPattern (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withPointcutMethodAnnotationPattern(@Nullable Pattern value) {
if (this.pointcutMethodAnnotationPattern == value) return this;
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
value,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object with elements that replace the content of {@link Advice#pointcutMethodParameterTypes() pointcutMethodParameterTypes}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAdvice withPointcutMethodParameterTypes(Object... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
newValue,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object with elements that replace the content of {@link Advice#pointcutMethodParameterTypes() pointcutMethodParameterTypes}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of pointcutMethodParameterTypes elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAdvice withPointcutMethodParameterTypes(Iterable extends Object> elements) {
if (this.pointcutMethodParameterTypes == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
newValue,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#travelerType() travelerType} 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 travelerType (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withTravelerType(@Nullable Type value) {
if (this.travelerType == value) return this;
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
value,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#isEnabledAdvice() isEnabledAdvice} 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 isEnabledAdvice (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withIsEnabledAdvice(@Nullable Method value) {
if (this.isEnabledAdvice == value) return this;
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
value,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#onBeforeAdvice() onBeforeAdvice} 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 onBeforeAdvice (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withOnBeforeAdvice(@Nullable Method value) {
if (this.onBeforeAdvice == value) return this;
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
value,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#onReturnAdvice() onReturnAdvice} 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 onReturnAdvice (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withOnReturnAdvice(@Nullable Method value) {
if (this.onReturnAdvice == value) return this;
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
value,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#onThrowAdvice() onThrowAdvice} 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 onThrowAdvice (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withOnThrowAdvice(@Nullable Method value) {
if (this.onThrowAdvice == value) return this;
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
value,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#onAfterAdvice() onAfterAdvice} 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 onAfterAdvice (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withOnAfterAdvice(@Nullable Method value) {
if (this.onAfterAdvice == value) return this;
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
value,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object with elements that replace the content of {@link Advice#isEnabledParameters() isEnabledParameters}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAdvice withIsEnabledParameters(Advice.AdviceParameter... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
newValue,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object with elements that replace the content of {@link Advice#isEnabledParameters() isEnabledParameters}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of isEnabledParameters elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAdvice withIsEnabledParameters(Iterable extends Advice.AdviceParameter> elements) {
if (this.isEnabledParameters == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
newValue,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object with elements that replace the content of {@link Advice#onBeforeParameters() onBeforeParameters}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAdvice withOnBeforeParameters(Advice.AdviceParameter... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
newValue,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object with elements that replace the content of {@link Advice#onBeforeParameters() onBeforeParameters}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of onBeforeParameters elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAdvice withOnBeforeParameters(Iterable extends Advice.AdviceParameter> elements) {
if (this.onBeforeParameters == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
newValue,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object with elements that replace the content of {@link Advice#onReturnParameters() onReturnParameters}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAdvice withOnReturnParameters(Advice.AdviceParameter... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
newValue,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object with elements that replace the content of {@link Advice#onReturnParameters() onReturnParameters}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of onReturnParameters elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAdvice withOnReturnParameters(Iterable extends Advice.AdviceParameter> elements) {
if (this.onReturnParameters == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
newValue,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object with elements that replace the content of {@link Advice#onThrowParameters() onThrowParameters}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAdvice withOnThrowParameters(Advice.AdviceParameter... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
newValue,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object with elements that replace the content of {@link Advice#onThrowParameters() onThrowParameters}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of onThrowParameters elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAdvice withOnThrowParameters(Iterable extends Advice.AdviceParameter> elements) {
if (this.onThrowParameters == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
newValue,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object with elements that replace the content of {@link Advice#onAfterParameters() onAfterParameters}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAdvice withOnAfterParameters(Advice.AdviceParameter... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
newValue,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object with elements that replace the content of {@link Advice#onAfterParameters() onAfterParameters}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of onAfterParameters elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableAdvice withOnAfterParameters(Iterable extends Advice.AdviceParameter> elements) {
if (this.onAfterParameters == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
newValue,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#hasBindThreadContext() hasBindThreadContext} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for hasBindThreadContext
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withHasBindThreadContext(boolean value) {
if (this.hasBindThreadContext == value) return this;
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
value,
this.hasBindOptionalThreadContext,
this.reweavable);
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#hasBindOptionalThreadContext() hasBindOptionalThreadContext} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for hasBindOptionalThreadContext
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withHasBindOptionalThreadContext(boolean value) {
if (this.hasBindOptionalThreadContext == value) return this;
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
value,
this.reweavable);
}
/**
* Copy the current immutable object by setting a value for the {@link Advice#reweavable() reweavable} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for reweavable
* @return A modified copy of the {@code this} object
*/
public final ImmutableAdvice withReweavable(boolean value) {
if (this.reweavable == value) return this;
return new ImmutableAdvice(
this.pointcut,
this.adviceType,
this.pointcutClassName,
this.pointcutClassNamePattern,
this.pointcutClassNameAnnotationPattern,
this.pointcutMethodDeclaringClassName,
this.pointcutMethodDeclaringClassNamePattern,
this.pointcutMethodNamePattern,
this.pointcutMethodAnnotationPattern,
this.pointcutMethodParameterTypes,
this.travelerType,
this.isEnabledAdvice,
this.onBeforeAdvice,
this.onReturnAdvice,
this.onThrowAdvice,
this.onAfterAdvice,
this.isEnabledParameters,
this.onBeforeParameters,
this.onReturnParameters,
this.onThrowParameters,
this.onAfterParameters,
this.hasBindThreadContext,
this.hasBindOptionalThreadContext,
value);
}
/**
* This instance is equal to all instances of {@code ImmutableAdvice} 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 ImmutableAdvice
&& equalTo((ImmutableAdvice) another);
}
private boolean equalTo(ImmutableAdvice another) {
return pointcut.equals(another.pointcut)
&& adviceType.equals(another.adviceType)
&& pointcutClassName.equals(another.pointcutClassName)
&& Objects.equal(pointcutClassNamePattern, another.pointcutClassNamePattern)
&& Objects.equal(pointcutClassNameAnnotationPattern, another.pointcutClassNameAnnotationPattern)
&& pointcutMethodDeclaringClassName.equals(another.pointcutMethodDeclaringClassName)
&& Objects.equal(pointcutMethodDeclaringClassNamePattern, another.pointcutMethodDeclaringClassNamePattern)
&& Objects.equal(pointcutMethodNamePattern, another.pointcutMethodNamePattern)
&& Objects.equal(pointcutMethodAnnotationPattern, another.pointcutMethodAnnotationPattern)
&& pointcutMethodParameterTypes.equals(another.pointcutMethodParameterTypes)
&& Objects.equal(travelerType, another.travelerType)
&& Objects.equal(isEnabledAdvice, another.isEnabledAdvice)
&& Objects.equal(onBeforeAdvice, another.onBeforeAdvice)
&& Objects.equal(onReturnAdvice, another.onReturnAdvice)
&& Objects.equal(onThrowAdvice, another.onThrowAdvice)
&& Objects.equal(onAfterAdvice, another.onAfterAdvice)
&& isEnabledParameters.equals(another.isEnabledParameters)
&& onBeforeParameters.equals(another.onBeforeParameters)
&& onReturnParameters.equals(another.onReturnParameters)
&& onThrowParameters.equals(another.onThrowParameters)
&& onAfterParameters.equals(another.onAfterParameters)
&& hasBindThreadContext == another.hasBindThreadContext
&& hasBindOptionalThreadContext == another.hasBindOptionalThreadContext
&& reweavable == another.reweavable
&& classMetaTypes.equals(another.classMetaTypes)
&& methodMetaTypes.equals(another.methodMetaTypes);
}
/**
* Computes a hash code from attributes: {@code pointcut}, {@code adviceType}, {@code pointcutClassName}, {@code pointcutClassNamePattern}, {@code pointcutClassNameAnnotationPattern}, {@code pointcutMethodDeclaringClassName}, {@code pointcutMethodDeclaringClassNamePattern}, {@code pointcutMethodNamePattern}, {@code pointcutMethodAnnotationPattern}, {@code pointcutMethodParameterTypes}, {@code travelerType}, {@code isEnabledAdvice}, {@code onBeforeAdvice}, {@code onReturnAdvice}, {@code onThrowAdvice}, {@code onAfterAdvice}, {@code isEnabledParameters}, {@code onBeforeParameters}, {@code onReturnParameters}, {@code onThrowParameters}, {@code onAfterParameters}, {@code hasBindThreadContext}, {@code hasBindOptionalThreadContext}, {@code reweavable}, {@code classMetaTypes}, {@code methodMetaTypes}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 31;
h = h * 17 + pointcut.hashCode();
h = h * 17 + adviceType.hashCode();
h = h * 17 + pointcutClassName.hashCode();
h = h * 17 + Objects.hashCode(pointcutClassNamePattern);
h = h * 17 + Objects.hashCode(pointcutClassNameAnnotationPattern);
h = h * 17 + pointcutMethodDeclaringClassName.hashCode();
h = h * 17 + Objects.hashCode(pointcutMethodDeclaringClassNamePattern);
h = h * 17 + Objects.hashCode(pointcutMethodNamePattern);
h = h * 17 + Objects.hashCode(pointcutMethodAnnotationPattern);
h = h * 17 + pointcutMethodParameterTypes.hashCode();
h = h * 17 + Objects.hashCode(travelerType);
h = h * 17 + Objects.hashCode(isEnabledAdvice);
h = h * 17 + Objects.hashCode(onBeforeAdvice);
h = h * 17 + Objects.hashCode(onReturnAdvice);
h = h * 17 + Objects.hashCode(onThrowAdvice);
h = h * 17 + Objects.hashCode(onAfterAdvice);
h = h * 17 + isEnabledParameters.hashCode();
h = h * 17 + onBeforeParameters.hashCode();
h = h * 17 + onReturnParameters.hashCode();
h = h * 17 + onThrowParameters.hashCode();
h = h * 17 + onAfterParameters.hashCode();
h = h * 17 + Booleans.hashCode(hasBindThreadContext);
h = h * 17 + Booleans.hashCode(hasBindOptionalThreadContext);
h = h * 17 + Booleans.hashCode(reweavable);
h = h * 17 + classMetaTypes.hashCode();
h = h * 17 + methodMetaTypes.hashCode();
return h;
}
/**
* Prints the immutable value {@code Advice...} with all non-generated
* and non-auxiliary attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("Advice")
.add("pointcut", pointcut)
.add("adviceType", adviceType)
.add("pointcutClassName", pointcutClassName)
.add("pointcutClassNamePattern", pointcutClassNamePattern)
.add("pointcutClassNameAnnotationPattern", pointcutClassNameAnnotationPattern)
.add("pointcutMethodDeclaringClassName", pointcutMethodDeclaringClassName)
.add("pointcutMethodDeclaringClassNamePattern", pointcutMethodDeclaringClassNamePattern)
.add("pointcutMethodNamePattern", pointcutMethodNamePattern)
.add("pointcutMethodAnnotationPattern", pointcutMethodAnnotationPattern)
.add("pointcutMethodParameterTypes", pointcutMethodParameterTypes)
.add("travelerType", travelerType)
.add("isEnabledAdvice", isEnabledAdvice)
.add("onBeforeAdvice", onBeforeAdvice)
.add("onReturnAdvice", onReturnAdvice)
.add("onThrowAdvice", onThrowAdvice)
.add("onAfterAdvice", onAfterAdvice)
.add("isEnabledParameters", isEnabledParameters)
.add("onBeforeParameters", onBeforeParameters)
.add("onReturnParameters", onReturnParameters)
.add("onThrowParameters", onThrowParameters)
.add("onAfterParameters", onAfterParameters)
.add("hasBindThreadContext", hasBindThreadContext)
.add("hasBindOptionalThreadContext", hasBindOptionalThreadContext)
.add("reweavable", reweavable)
.add("classMetaTypes", classMetaTypes)
.add("methodMetaTypes", methodMetaTypes)
.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 Advice {
@Nullable Pointcut pointcut;
@Nullable Type adviceType;
@Nullable String pointcutClassName;
@Nullable Pattern pointcutClassNamePattern;
@Nullable Pattern pointcutClassNameAnnotationPattern;
@Nullable String pointcutMethodDeclaringClassName;
@Nullable Pattern pointcutMethodDeclaringClassNamePattern;
@Nullable Pattern pointcutMethodNamePattern;
@Nullable Pattern pointcutMethodAnnotationPattern;
List pointcutMethodParameterTypes = ImmutableList.of();
@Nullable Type travelerType;
@Nullable Method isEnabledAdvice;
@Nullable Method onBeforeAdvice;
@Nullable Method onReturnAdvice;
@Nullable Method onThrowAdvice;
@Nullable Method onAfterAdvice;
ImmutableList isEnabledParameters = ImmutableList.of();
ImmutableList onBeforeParameters = ImmutableList.of();
ImmutableList onReturnParameters = ImmutableList.of();
ImmutableList onThrowParameters = ImmutableList.of();
ImmutableList onAfterParameters = ImmutableList.of();
@Nullable Boolean hasBindThreadContext;
@Nullable Boolean hasBindOptionalThreadContext;
@Nullable Boolean reweavable;
@JsonProperty
public void setPointcut(Pointcut pointcut) {
this.pointcut = pointcut;
}
@JsonProperty
public void setAdviceType(Type adviceType) {
this.adviceType = adviceType;
}
@JsonProperty
public void setPointcutClassName(String pointcutClassName) {
this.pointcutClassName = pointcutClassName;
}
@JsonProperty
public void setPointcutClassNamePattern(@Nullable Pattern pointcutClassNamePattern) {
this.pointcutClassNamePattern = pointcutClassNamePattern;
}
@JsonProperty
public void setPointcutClassNameAnnotationPattern(@Nullable Pattern pointcutClassNameAnnotationPattern) {
this.pointcutClassNameAnnotationPattern = pointcutClassNameAnnotationPattern;
}
@JsonProperty
public void setPointcutMethodDeclaringClassName(String pointcutMethodDeclaringClassName) {
this.pointcutMethodDeclaringClassName = pointcutMethodDeclaringClassName;
}
@JsonProperty
public void setPointcutMethodDeclaringClassNamePattern(@Nullable Pattern pointcutMethodDeclaringClassNamePattern) {
this.pointcutMethodDeclaringClassNamePattern = pointcutMethodDeclaringClassNamePattern;
}
@JsonProperty
public void setPointcutMethodNamePattern(@Nullable Pattern pointcutMethodNamePattern) {
this.pointcutMethodNamePattern = pointcutMethodNamePattern;
}
@JsonProperty
public void setPointcutMethodAnnotationPattern(@Nullable Pattern pointcutMethodAnnotationPattern) {
this.pointcutMethodAnnotationPattern = pointcutMethodAnnotationPattern;
}
@JsonProperty
public void setPointcutMethodParameterTypes(List pointcutMethodParameterTypes) {
this.pointcutMethodParameterTypes = pointcutMethodParameterTypes;
}
@JsonProperty
public void setTravelerType(@Nullable Type travelerType) {
this.travelerType = travelerType;
}
@JsonProperty
public void setIsEnabledAdvice(@Nullable Method isEnabledAdvice) {
this.isEnabledAdvice = isEnabledAdvice;
}
@JsonProperty
public void setOnBeforeAdvice(@Nullable Method onBeforeAdvice) {
this.onBeforeAdvice = onBeforeAdvice;
}
@JsonProperty
public void setOnReturnAdvice(@Nullable Method onReturnAdvice) {
this.onReturnAdvice = onReturnAdvice;
}
@JsonProperty
public void setOnThrowAdvice(@Nullable Method onThrowAdvice) {
this.onThrowAdvice = onThrowAdvice;
}
@JsonProperty
public void setOnAfterAdvice(@Nullable Method onAfterAdvice) {
this.onAfterAdvice = onAfterAdvice;
}
@JsonProperty
public void setIsEnabledParameters(ImmutableList isEnabledParameters) {
this.isEnabledParameters = isEnabledParameters;
}
@JsonProperty
public void setOnBeforeParameters(ImmutableList onBeforeParameters) {
this.onBeforeParameters = onBeforeParameters;
}
@JsonProperty
public void setOnReturnParameters(ImmutableList onReturnParameters) {
this.onReturnParameters = onReturnParameters;
}
@JsonProperty
public void setOnThrowParameters(ImmutableList onThrowParameters) {
this.onThrowParameters = onThrowParameters;
}
@JsonProperty
public void setOnAfterParameters(ImmutableList onAfterParameters) {
this.onAfterParameters = onAfterParameters;
}
@JsonProperty
public void setHasBindThreadContext(boolean hasBindThreadContext) {
this.hasBindThreadContext = hasBindThreadContext;
}
@JsonProperty
public void setHasBindOptionalThreadContext(boolean hasBindOptionalThreadContext) {
this.hasBindOptionalThreadContext = hasBindOptionalThreadContext;
}
@JsonProperty
public void setReweavable(boolean reweavable) {
this.reweavable = reweavable;
}
@Override
Pointcut pointcut() { throw new UnsupportedOperationException(); }
@Override
Type adviceType() { throw new UnsupportedOperationException(); }
@Override
String pointcutClassName() { throw new UnsupportedOperationException(); }
@Override
Pattern pointcutClassNamePattern() { throw new UnsupportedOperationException(); }
@Override
Pattern pointcutClassNameAnnotationPattern() { throw new UnsupportedOperationException(); }
@Override
String pointcutMethodDeclaringClassName() { throw new UnsupportedOperationException(); }
@Override
Pattern pointcutMethodDeclaringClassNamePattern() { throw new UnsupportedOperationException(); }
@Override
Pattern pointcutMethodNamePattern() { throw new UnsupportedOperationException(); }
@Override
Pattern pointcutMethodAnnotationPattern() { throw new UnsupportedOperationException(); }
@Override
List pointcutMethodParameterTypes() { throw new UnsupportedOperationException(); }
@Override
Type travelerType() { throw new UnsupportedOperationException(); }
@Override
Method isEnabledAdvice() { throw new UnsupportedOperationException(); }
@Override
Method onBeforeAdvice() { throw new UnsupportedOperationException(); }
@Override
Method onReturnAdvice() { throw new UnsupportedOperationException(); }
@Override
Method onThrowAdvice() { throw new UnsupportedOperationException(); }
@Override
Method onAfterAdvice() { throw new UnsupportedOperationException(); }
@Override
ImmutableList isEnabledParameters() { throw new UnsupportedOperationException(); }
@Override
ImmutableList onBeforeParameters() { throw new UnsupportedOperationException(); }
@Override
ImmutableList onReturnParameters() { throw new UnsupportedOperationException(); }
@Override
ImmutableList onThrowParameters() { throw new UnsupportedOperationException(); }
@Override
ImmutableList onAfterParameters() { throw new UnsupportedOperationException(); }
@Override
boolean hasBindThreadContext() { throw new UnsupportedOperationException(); }
@Override
boolean hasBindOptionalThreadContext() { throw new UnsupportedOperationException(); }
@Override
boolean reweavable() { throw new UnsupportedOperationException(); }
@Override
ImmutableSet classMetaTypes() { throw new UnsupportedOperationException(); }
@Override
ImmutableSet methodMetaTypes() { 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 ImmutableAdvice fromJson(Json json) {
ImmutableAdvice.Builder builder = ImmutableAdvice.builder();
if (json.pointcut != null) {
builder.pointcut(json.pointcut);
}
if (json.adviceType != null) {
builder.adviceType(json.adviceType);
}
if (json.pointcutClassName != null) {
builder.pointcutClassName(json.pointcutClassName);
}
if (json.pointcutClassNamePattern != null) {
builder.pointcutClassNamePattern(json.pointcutClassNamePattern);
}
if (json.pointcutClassNameAnnotationPattern != null) {
builder.pointcutClassNameAnnotationPattern(json.pointcutClassNameAnnotationPattern);
}
if (json.pointcutMethodDeclaringClassName != null) {
builder.pointcutMethodDeclaringClassName(json.pointcutMethodDeclaringClassName);
}
if (json.pointcutMethodDeclaringClassNamePattern != null) {
builder.pointcutMethodDeclaringClassNamePattern(json.pointcutMethodDeclaringClassNamePattern);
}
if (json.pointcutMethodNamePattern != null) {
builder.pointcutMethodNamePattern(json.pointcutMethodNamePattern);
}
if (json.pointcutMethodAnnotationPattern != null) {
builder.pointcutMethodAnnotationPattern(json.pointcutMethodAnnotationPattern);
}
if (json.pointcutMethodParameterTypes != null) {
builder.addAllPointcutMethodParameterTypes(json.pointcutMethodParameterTypes);
}
if (json.travelerType != null) {
builder.travelerType(json.travelerType);
}
if (json.isEnabledAdvice != null) {
builder.isEnabledAdvice(json.isEnabledAdvice);
}
if (json.onBeforeAdvice != null) {
builder.onBeforeAdvice(json.onBeforeAdvice);
}
if (json.onReturnAdvice != null) {
builder.onReturnAdvice(json.onReturnAdvice);
}
if (json.onThrowAdvice != null) {
builder.onThrowAdvice(json.onThrowAdvice);
}
if (json.onAfterAdvice != null) {
builder.onAfterAdvice(json.onAfterAdvice);
}
if (json.isEnabledParameters != null) {
builder.addAllIsEnabledParameters(json.isEnabledParameters);
}
if (json.onBeforeParameters != null) {
builder.addAllOnBeforeParameters(json.onBeforeParameters);
}
if (json.onReturnParameters != null) {
builder.addAllOnReturnParameters(json.onReturnParameters);
}
if (json.onThrowParameters != null) {
builder.addAllOnThrowParameters(json.onThrowParameters);
}
if (json.onAfterParameters != null) {
builder.addAllOnAfterParameters(json.onAfterParameters);
}
if (json.hasBindThreadContext != null) {
builder.hasBindThreadContext(json.hasBindThreadContext);
}
if (json.hasBindOptionalThreadContext != null) {
builder.hasBindOptionalThreadContext(json.hasBindOptionalThreadContext);
}
if (json.reweavable != null) {
builder.reweavable(json.reweavable);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link Advice} 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 Advice instance
*/
public static ImmutableAdvice copyOf(Advice instance) {
if (instance instanceof ImmutableAdvice) {
return (ImmutableAdvice) instance;
}
return ImmutableAdvice.builder()
.copyFrom(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableAdvice ImmutableAdvice}.
* @return A new ImmutableAdvice builder
*/
public static ImmutableAdvice.Builder builder() {
return new ImmutableAdvice.Builder();
}
/**
* Builds instances of type {@link ImmutableAdvice ImmutableAdvice}.
* 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
public static final class Builder {
private static final long INIT_BIT_POINTCUT = 0x1L;
private static final long INIT_BIT_ADVICE_TYPE = 0x2L;
private static final long INIT_BIT_POINTCUT_CLASS_NAME = 0x4L;
private static final long INIT_BIT_POINTCUT_METHOD_DECLARING_CLASS_NAME = 0x8L;
private static final long INIT_BIT_HAS_BIND_THREAD_CONTEXT = 0x10L;
private static final long INIT_BIT_HAS_BIND_OPTIONAL_THREAD_CONTEXT = 0x20L;
private static final long INIT_BIT_REWEAVABLE = 0x40L;
private long initBits = 0x7f;
private @Nullable Pointcut pointcut;
private @Nullable Type adviceType;
private @Nullable String pointcutClassName;
private @Nullable Pattern pointcutClassNamePattern;
private @Nullable Pattern pointcutClassNameAnnotationPattern;
private @Nullable String pointcutMethodDeclaringClassName;
private @Nullable Pattern pointcutMethodDeclaringClassNamePattern;
private @Nullable Pattern pointcutMethodNamePattern;
private @Nullable Pattern pointcutMethodAnnotationPattern;
private ImmutableList.Builder pointcutMethodParameterTypesBuilder = ImmutableList.builder();
private @Nullable Type travelerType;
private @Nullable Method isEnabledAdvice;
private @Nullable Method onBeforeAdvice;
private @Nullable Method onReturnAdvice;
private @Nullable Method onThrowAdvice;
private @Nullable Method onAfterAdvice;
private ImmutableList.Builder isEnabledParametersBuilder = ImmutableList.builder();
private ImmutableList.Builder onBeforeParametersBuilder = ImmutableList.builder();
private ImmutableList.Builder onReturnParametersBuilder = ImmutableList.builder();
private ImmutableList.Builder onThrowParametersBuilder = ImmutableList.builder();
private ImmutableList.Builder onAfterParametersBuilder = ImmutableList.builder();
private boolean hasBindThreadContext;
private boolean hasBindOptionalThreadContext;
private boolean reweavable;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code Advice} 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(Advice instance) {
Preconditions.checkNotNull(instance, "instance");
pointcut(instance.pointcut());
adviceType(instance.adviceType());
pointcutClassName(instance.pointcutClassName());
@Nullable Pattern pointcutClassNamePatternValue = instance.pointcutClassNamePattern();
if (pointcutClassNamePatternValue != null) {
pointcutClassNamePattern(pointcutClassNamePatternValue);
}
@Nullable Pattern pointcutClassNameAnnotationPatternValue = instance.pointcutClassNameAnnotationPattern();
if (pointcutClassNameAnnotationPatternValue != null) {
pointcutClassNameAnnotationPattern(pointcutClassNameAnnotationPatternValue);
}
pointcutMethodDeclaringClassName(instance.pointcutMethodDeclaringClassName());
@Nullable Pattern pointcutMethodDeclaringClassNamePatternValue = instance.pointcutMethodDeclaringClassNamePattern();
if (pointcutMethodDeclaringClassNamePatternValue != null) {
pointcutMethodDeclaringClassNamePattern(pointcutMethodDeclaringClassNamePatternValue);
}
@Nullable Pattern pointcutMethodNamePatternValue = instance.pointcutMethodNamePattern();
if (pointcutMethodNamePatternValue != null) {
pointcutMethodNamePattern(pointcutMethodNamePatternValue);
}
@Nullable Pattern pointcutMethodAnnotationPatternValue = instance.pointcutMethodAnnotationPattern();
if (pointcutMethodAnnotationPatternValue != null) {
pointcutMethodAnnotationPattern(pointcutMethodAnnotationPatternValue);
}
addAllPointcutMethodParameterTypes(instance.pointcutMethodParameterTypes());
@Nullable Type travelerTypeValue = instance.travelerType();
if (travelerTypeValue != null) {
travelerType(travelerTypeValue);
}
@Nullable Method isEnabledAdviceValue = instance.isEnabledAdvice();
if (isEnabledAdviceValue != null) {
isEnabledAdvice(isEnabledAdviceValue);
}
@Nullable Method onBeforeAdviceValue = instance.onBeforeAdvice();
if (onBeforeAdviceValue != null) {
onBeforeAdvice(onBeforeAdviceValue);
}
@Nullable Method onReturnAdviceValue = instance.onReturnAdvice();
if (onReturnAdviceValue != null) {
onReturnAdvice(onReturnAdviceValue);
}
@Nullable Method onThrowAdviceValue = instance.onThrowAdvice();
if (onThrowAdviceValue != null) {
onThrowAdvice(onThrowAdviceValue);
}
@Nullable Method onAfterAdviceValue = instance.onAfterAdvice();
if (onAfterAdviceValue != null) {
onAfterAdvice(onAfterAdviceValue);
}
addAllIsEnabledParameters(instance.isEnabledParameters());
addAllOnBeforeParameters(instance.onBeforeParameters());
addAllOnReturnParameters(instance.onReturnParameters());
addAllOnThrowParameters(instance.onThrowParameters());
addAllOnAfterParameters(instance.onAfterParameters());
hasBindThreadContext(instance.hasBindThreadContext());
hasBindOptionalThreadContext(instance.hasBindOptionalThreadContext());
reweavable(instance.reweavable());
return this;
}
/**
* Initializes the value for the {@link Advice#pointcut() pointcut} attribute.
* @param pointcut The value for pointcut
* @return {@code this} builder for use in a chained invocation
*/
public final Builder pointcut(Pointcut pointcut) {
this.pointcut = Preconditions.checkNotNull(pointcut, "pointcut");
initBits &= ~INIT_BIT_POINTCUT;
return this;
}
/**
* Initializes the value for the {@link Advice#adviceType() adviceType} attribute.
* @param adviceType The value for adviceType
* @return {@code this} builder for use in a chained invocation
*/
public final Builder adviceType(Type adviceType) {
this.adviceType = Preconditions.checkNotNull(adviceType, "adviceType");
initBits &= ~INIT_BIT_ADVICE_TYPE;
return this;
}
/**
* Initializes the value for the {@link Advice#pointcutClassName() pointcutClassName} attribute.
* @param pointcutClassName The value for pointcutClassName
* @return {@code this} builder for use in a chained invocation
*/
public final Builder pointcutClassName(String pointcutClassName) {
this.pointcutClassName = Preconditions.checkNotNull(pointcutClassName, "pointcutClassName");
initBits &= ~INIT_BIT_POINTCUT_CLASS_NAME;
return this;
}
/**
* Initializes the value for the {@link Advice#pointcutClassNamePattern() pointcutClassNamePattern} attribute.
* @param pointcutClassNamePattern The value for pointcutClassNamePattern (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder pointcutClassNamePattern(@Nullable Pattern pointcutClassNamePattern) {
this.pointcutClassNamePattern = pointcutClassNamePattern;
return this;
}
/**
* Initializes the value for the {@link Advice#pointcutClassNameAnnotationPattern() pointcutClassNameAnnotationPattern} attribute.
* @param pointcutClassNameAnnotationPattern The value for pointcutClassNameAnnotationPattern (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder pointcutClassNameAnnotationPattern(@Nullable Pattern pointcutClassNameAnnotationPattern) {
this.pointcutClassNameAnnotationPattern = pointcutClassNameAnnotationPattern;
return this;
}
/**
* Initializes the value for the {@link Advice#pointcutMethodDeclaringClassName() pointcutMethodDeclaringClassName} attribute.
* @param pointcutMethodDeclaringClassName The value for pointcutMethodDeclaringClassName
* @return {@code this} builder for use in a chained invocation
*/
public final Builder pointcutMethodDeclaringClassName(String pointcutMethodDeclaringClassName) {
this.pointcutMethodDeclaringClassName = Preconditions.checkNotNull(pointcutMethodDeclaringClassName, "pointcutMethodDeclaringClassName");
initBits &= ~INIT_BIT_POINTCUT_METHOD_DECLARING_CLASS_NAME;
return this;
}
/**
* Initializes the value for the {@link Advice#pointcutMethodDeclaringClassNamePattern() pointcutMethodDeclaringClassNamePattern} attribute.
* @param pointcutMethodDeclaringClassNamePattern The value for pointcutMethodDeclaringClassNamePattern (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder pointcutMethodDeclaringClassNamePattern(@Nullable Pattern pointcutMethodDeclaringClassNamePattern) {
this.pointcutMethodDeclaringClassNamePattern = pointcutMethodDeclaringClassNamePattern;
return this;
}
/**
* Initializes the value for the {@link Advice#pointcutMethodNamePattern() pointcutMethodNamePattern} attribute.
* @param pointcutMethodNamePattern The value for pointcutMethodNamePattern (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder pointcutMethodNamePattern(@Nullable Pattern pointcutMethodNamePattern) {
this.pointcutMethodNamePattern = pointcutMethodNamePattern;
return this;
}
/**
* Initializes the value for the {@link Advice#pointcutMethodAnnotationPattern() pointcutMethodAnnotationPattern} attribute.
* @param pointcutMethodAnnotationPattern The value for pointcutMethodAnnotationPattern (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder pointcutMethodAnnotationPattern(@Nullable Pattern pointcutMethodAnnotationPattern) {
this.pointcutMethodAnnotationPattern = pointcutMethodAnnotationPattern;
return this;
}
/**
* Adds one element to {@link Advice#pointcutMethodParameterTypes() pointcutMethodParameterTypes} list.
* @param element A pointcutMethodParameterTypes element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addPointcutMethodParameterTypes(Object element) {
pointcutMethodParameterTypesBuilder.add(element);
return this;
}
/**
* Adds elements to {@link Advice#pointcutMethodParameterTypes() pointcutMethodParameterTypes} list.
* @param elements An array of pointcutMethodParameterTypes elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addPointcutMethodParameterTypes(Object... elements) {
pointcutMethodParameterTypesBuilder.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link Advice#pointcutMethodParameterTypes() pointcutMethodParameterTypes} list.
* @param elements An iterable of pointcutMethodParameterTypes elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder pointcutMethodParameterTypes(Iterable extends Object> elements) {
pointcutMethodParameterTypesBuilder = ImmutableList.builder();
return addAllPointcutMethodParameterTypes(elements);
}
/**
* Adds elements to {@link Advice#pointcutMethodParameterTypes() pointcutMethodParameterTypes} list.
* @param elements An iterable of pointcutMethodParameterTypes elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllPointcutMethodParameterTypes(Iterable extends Object> elements) {
pointcutMethodParameterTypesBuilder.addAll(elements);
return this;
}
/**
* Initializes the value for the {@link Advice#travelerType() travelerType} attribute.
* @param travelerType The value for travelerType (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder travelerType(@Nullable Type travelerType) {
this.travelerType = travelerType;
return this;
}
/**
* Initializes the value for the {@link Advice#isEnabledAdvice() isEnabledAdvice} attribute.
* @param isEnabledAdvice The value for isEnabledAdvice (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder isEnabledAdvice(@Nullable Method isEnabledAdvice) {
this.isEnabledAdvice = isEnabledAdvice;
return this;
}
/**
* Initializes the value for the {@link Advice#onBeforeAdvice() onBeforeAdvice} attribute.
* @param onBeforeAdvice The value for onBeforeAdvice (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder onBeforeAdvice(@Nullable Method onBeforeAdvice) {
this.onBeforeAdvice = onBeforeAdvice;
return this;
}
/**
* Initializes the value for the {@link Advice#onReturnAdvice() onReturnAdvice} attribute.
* @param onReturnAdvice The value for onReturnAdvice (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder onReturnAdvice(@Nullable Method onReturnAdvice) {
this.onReturnAdvice = onReturnAdvice;
return this;
}
/**
* Initializes the value for the {@link Advice#onThrowAdvice() onThrowAdvice} attribute.
* @param onThrowAdvice The value for onThrowAdvice (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder onThrowAdvice(@Nullable Method onThrowAdvice) {
this.onThrowAdvice = onThrowAdvice;
return this;
}
/**
* Initializes the value for the {@link Advice#onAfterAdvice() onAfterAdvice} attribute.
* @param onAfterAdvice The value for onAfterAdvice (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder onAfterAdvice(@Nullable Method onAfterAdvice) {
this.onAfterAdvice = onAfterAdvice;
return this;
}
/**
* Adds one element to {@link Advice#isEnabledParameters() isEnabledParameters} list.
* @param element A isEnabledParameters element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addIsEnabledParameters(Advice.AdviceParameter element) {
isEnabledParametersBuilder.add(element);
return this;
}
/**
* Adds elements to {@link Advice#isEnabledParameters() isEnabledParameters} list.
* @param elements An array of isEnabledParameters elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addIsEnabledParameters(Advice.AdviceParameter... elements) {
isEnabledParametersBuilder.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link Advice#isEnabledParameters() isEnabledParameters} list.
* @param elements An iterable of isEnabledParameters elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder isEnabledParameters(Iterable extends Advice.AdviceParameter> elements) {
isEnabledParametersBuilder = ImmutableList.builder();
return addAllIsEnabledParameters(elements);
}
/**
* Adds elements to {@link Advice#isEnabledParameters() isEnabledParameters} list.
* @param elements An iterable of isEnabledParameters elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllIsEnabledParameters(Iterable extends Advice.AdviceParameter> elements) {
isEnabledParametersBuilder.addAll(elements);
return this;
}
/**
* Adds one element to {@link Advice#onBeforeParameters() onBeforeParameters} list.
* @param element A onBeforeParameters element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addOnBeforeParameters(Advice.AdviceParameter element) {
onBeforeParametersBuilder.add(element);
return this;
}
/**
* Adds elements to {@link Advice#onBeforeParameters() onBeforeParameters} list.
* @param elements An array of onBeforeParameters elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addOnBeforeParameters(Advice.AdviceParameter... elements) {
onBeforeParametersBuilder.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link Advice#onBeforeParameters() onBeforeParameters} list.
* @param elements An iterable of onBeforeParameters elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder onBeforeParameters(Iterable extends Advice.AdviceParameter> elements) {
onBeforeParametersBuilder = ImmutableList.builder();
return addAllOnBeforeParameters(elements);
}
/**
* Adds elements to {@link Advice#onBeforeParameters() onBeforeParameters} list.
* @param elements An iterable of onBeforeParameters elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllOnBeforeParameters(Iterable extends Advice.AdviceParameter> elements) {
onBeforeParametersBuilder.addAll(elements);
return this;
}
/**
* Adds one element to {@link Advice#onReturnParameters() onReturnParameters} list.
* @param element A onReturnParameters element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addOnReturnParameters(Advice.AdviceParameter element) {
onReturnParametersBuilder.add(element);
return this;
}
/**
* Adds elements to {@link Advice#onReturnParameters() onReturnParameters} list.
* @param elements An array of onReturnParameters elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addOnReturnParameters(Advice.AdviceParameter... elements) {
onReturnParametersBuilder.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link Advice#onReturnParameters() onReturnParameters} list.
* @param elements An iterable of onReturnParameters elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder onReturnParameters(Iterable extends Advice.AdviceParameter> elements) {
onReturnParametersBuilder = ImmutableList.builder();
return addAllOnReturnParameters(elements);
}
/**
* Adds elements to {@link Advice#onReturnParameters() onReturnParameters} list.
* @param elements An iterable of onReturnParameters elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllOnReturnParameters(Iterable extends Advice.AdviceParameter> elements) {
onReturnParametersBuilder.addAll(elements);
return this;
}
/**
* Adds one element to {@link Advice#onThrowParameters() onThrowParameters} list.
* @param element A onThrowParameters element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addOnThrowParameters(Advice.AdviceParameter element) {
onThrowParametersBuilder.add(element);
return this;
}
/**
* Adds elements to {@link Advice#onThrowParameters() onThrowParameters} list.
* @param elements An array of onThrowParameters elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addOnThrowParameters(Advice.AdviceParameter... elements) {
onThrowParametersBuilder.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link Advice#onThrowParameters() onThrowParameters} list.
* @param elements An iterable of onThrowParameters elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder onThrowParameters(Iterable extends Advice.AdviceParameter> elements) {
onThrowParametersBuilder = ImmutableList.builder();
return addAllOnThrowParameters(elements);
}
/**
* Adds elements to {@link Advice#onThrowParameters() onThrowParameters} list.
* @param elements An iterable of onThrowParameters elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllOnThrowParameters(Iterable extends Advice.AdviceParameter> elements) {
onThrowParametersBuilder.addAll(elements);
return this;
}
/**
* Adds one element to {@link Advice#onAfterParameters() onAfterParameters} list.
* @param element A onAfterParameters element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addOnAfterParameters(Advice.AdviceParameter element) {
onAfterParametersBuilder.add(element);
return this;
}
/**
* Adds elements to {@link Advice#onAfterParameters() onAfterParameters} list.
* @param elements An array of onAfterParameters elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addOnAfterParameters(Advice.AdviceParameter... elements) {
onAfterParametersBuilder.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link Advice#onAfterParameters() onAfterParameters} list.
* @param elements An iterable of onAfterParameters elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder onAfterParameters(Iterable extends Advice.AdviceParameter> elements) {
onAfterParametersBuilder = ImmutableList.builder();
return addAllOnAfterParameters(elements);
}
/**
* Adds elements to {@link Advice#onAfterParameters() onAfterParameters} list.
* @param elements An iterable of onAfterParameters elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllOnAfterParameters(Iterable extends Advice.AdviceParameter> elements) {
onAfterParametersBuilder.addAll(elements);
return this;
}
/**
* Initializes the value for the {@link Advice#hasBindThreadContext() hasBindThreadContext} attribute.
* @param hasBindThreadContext The value for hasBindThreadContext
* @return {@code this} builder for use in a chained invocation
*/
public final Builder hasBindThreadContext(boolean hasBindThreadContext) {
this.hasBindThreadContext = hasBindThreadContext;
initBits &= ~INIT_BIT_HAS_BIND_THREAD_CONTEXT;
return this;
}
/**
* Initializes the value for the {@link Advice#hasBindOptionalThreadContext() hasBindOptionalThreadContext} attribute.
* @param hasBindOptionalThreadContext The value for hasBindOptionalThreadContext
* @return {@code this} builder for use in a chained invocation
*/
public final Builder hasBindOptionalThreadContext(boolean hasBindOptionalThreadContext) {
this.hasBindOptionalThreadContext = hasBindOptionalThreadContext;
initBits &= ~INIT_BIT_HAS_BIND_OPTIONAL_THREAD_CONTEXT;
return this;
}
/**
* Initializes the value for the {@link Advice#reweavable() reweavable} attribute.
* @param reweavable The value for reweavable
* @return {@code this} builder for use in a chained invocation
*/
public final Builder reweavable(boolean reweavable) {
this.reweavable = reweavable;
initBits &= ~INIT_BIT_REWEAVABLE;
return this;
}
/**
* Builds a new {@link ImmutableAdvice ImmutableAdvice}.
* @return An immutable instance of Advice
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableAdvice build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableAdvice(
pointcut,
adviceType,
pointcutClassName,
pointcutClassNamePattern,
pointcutClassNameAnnotationPattern,
pointcutMethodDeclaringClassName,
pointcutMethodDeclaringClassNamePattern,
pointcutMethodNamePattern,
pointcutMethodAnnotationPattern,
pointcutMethodParameterTypesBuilder.build(),
travelerType,
isEnabledAdvice,
onBeforeAdvice,
onReturnAdvice,
onThrowAdvice,
onAfterAdvice,
isEnabledParametersBuilder.build(),
onBeforeParametersBuilder.build(),
onReturnParametersBuilder.build(),
onThrowParametersBuilder.build(),
onAfterParametersBuilder.build(),
hasBindThreadContext,
hasBindOptionalThreadContext,
reweavable);
}
private String formatRequiredAttributesMessage() {
List attributes = Lists.newArrayList();
if ((initBits & INIT_BIT_POINTCUT) != 0) attributes.add("pointcut");
if ((initBits & INIT_BIT_ADVICE_TYPE) != 0) attributes.add("adviceType");
if ((initBits & INIT_BIT_POINTCUT_CLASS_NAME) != 0) attributes.add("pointcutClassName");
if ((initBits & INIT_BIT_POINTCUT_METHOD_DECLARING_CLASS_NAME) != 0) attributes.add("pointcutMethodDeclaringClassName");
if ((initBits & INIT_BIT_HAS_BIND_THREAD_CONTEXT) != 0) attributes.add("hasBindThreadContext");
if ((initBits & INIT_BIT_HAS_BIND_OPTIONAL_THREAD_CONTEXT) != 0) attributes.add("hasBindOptionalThreadContext");
if ((initBits & INIT_BIT_REWEAVABLE) != 0) attributes.add("reweavable");
return "Cannot build Advice, some of required attributes are not set " + attributes;
}
}
}