Package net.bytebuddy.asm
Class AnnotationRemoval
java.lang.Object
net.bytebuddy.asm.AsmVisitorWrapper.AbstractBase
net.bytebuddy.asm.AnnotationRemoval
- All Implemented Interfaces:
AsmVisitorWrapper
A visitor wrapper that removes annotations from the instrumented type.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
A class visitor that removes annotations.private static class
A field visitor that removes annotations.private static class
Creates a visitor for removing annotations from methods and method parameters.Nested classes/interfaces inherited from interface net.bytebuddy.asm.AsmVisitorWrapper
AsmVisitorWrapper.AbstractBase, AsmVisitorWrapper.Compound, AsmVisitorWrapper.ForDeclaredFields, AsmVisitorWrapper.ForDeclaredMethods, AsmVisitorWrapper.NoOp
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ElementMatcher
<? super AnnotationDescription> Matches annotations that should be removed.private final ElementMatcher
<? super FieldDescription.InDefinedShape> Matches fields from which annotations should be removed.private static final int
Indicates that bother method annotations and method parameter annotations should be considered.private static final int
Indicates that neither method annotations and method parameter annotations should be considered.private static final int
Indicates that only method annotations should be considered.private static final int
Indicates that only method parameter annotations should be considered.private final ElementMatcher
<? super MethodDescription> Matches methods from which annotations should be removed.private final int
Indices the method parameter index from which annotations should be removed, or a negative value to indicate different treatment.private final boolean
true
if annotations on the type should be removed.Fields inherited from interface net.bytebuddy.asm.AsmVisitorWrapper
NO_FLAGS
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AnnotationRemoval
(boolean type, ElementMatcher<? super FieldDescription.InDefinedShape> fieldMatcher, ElementMatcher<? super MethodDescription> methodMatcher, ElementMatcher<? super AnnotationDescription> annotationMatcher, int parameters) Creates a visitor for annotation removal. -
Method Summary
Modifier and TypeMethodDescriptiononConstructorParameter
(ElementMatcher<? super MethodDescription> matcher, int parameter) Creates a visitor that removes annotations from the constructor parameters with the given index where the constructor matches the specified matcher.onConstructorParameters
(ElementMatcher<? super MethodDescription> matcher) Creates a visitor that removes annotations from constructor parameters where the constructor matches the specified matcher.onConstructors
(ElementMatcher<? super MethodDescription> matcher) Creates a visitor that removes annotations from constructors that match the specified matcher.onConstructorsAndParameters
(ElementMatcher<? super MethodDescription> matcher) Creates a visitor that removes annotations from constructors and their parameters that match the specified matcher.onFields
(ElementMatcher<? super FieldDescription> matcher) Creates a visitor that only removes annotations from fields that match the specified matcher.onInvokableParameter
(ElementMatcher<? super MethodDescription> matcher, int parameter) Creates a visitor that removes annotations from the constructor or method parameters with the given index where the constructor or method matches the specified matcher.onInvokableParameters
(ElementMatcher<? super MethodDescription> matcher) Creates a visitor that removes annotations from constructor or method parameters where the constructor or method matches the specified matcher.onInvokables
(ElementMatcher<? super MethodDescription> matcher) Creates a visitor that removes annotations from constructors or methods that match the specified matcher.onInvokablesAndParameters
(ElementMatcher<? super MethodDescription> matcher) Creates a visitor that removes annotations from constructors or methods and their parameters that match the specified matcher.onMethodParameter
(ElementMatcher<? super MethodDescription> matcher, int parameter) Creates a visitor that removes annotations from the method parameters with the given index where the method matches the specified matcher.onMethodParameters
(ElementMatcher<? super MethodDescription> matcher) Creates a visitor that removes annotations from method parameters where the method matches the specified matcher.onMethods
(ElementMatcher<? super MethodDescription> matcher) Creates a visitor that removes annotations from methods that match the specified matcher.onMethodsAndParameters
(ElementMatcher<? super MethodDescription> matcher) Creates a visitor that removes annotations from methods and their parameters that match the specified matcher.onType()
Creates a visitor that only removes annotations from the type.static AnnotationRemoval
strip
(ElementMatcher<? super AnnotationDescription> matcher) Creates a visitor that removes all annotations that match the specified matcher from the instrumented type.org.objectweb.asm.ClassVisitor
wrap
(TypeDescription instrumentedType, org.objectweb.asm.ClassVisitor classVisitor, Implementation.Context implementationContext, TypePool typePool, FieldList<FieldDescription.InDefinedShape> fields, MethodList<?> methods, int writerFlags, int readerFlags) Applies aClassVisitorWrapper
to the creation of aDynamicType
.Methods inherited from class net.bytebuddy.asm.AsmVisitorWrapper.AbstractBase
mergeReader, mergeWriter
-
Field Details
-
METHOD_NONE
private static final int METHOD_NONEIndicates that neither method annotations and method parameter annotations should be considered.- See Also:
-
METHOD_ALL
private static final int METHOD_ALLIndicates that bother method annotations and method parameter annotations should be considered.- See Also:
-
METHOD_ONLY
private static final int METHOD_ONLYIndicates that only method annotations should be considered.- See Also:
-
METHOD_PARAMETERS
private static final int METHOD_PARAMETERSIndicates that only method parameter annotations should be considered.- See Also:
-
type
private final boolean typetrue
if annotations on the type should be removed. -
fieldMatcher
Matches fields from which annotations should be removed. -
methodMatcher
Matches methods from which annotations should be removed. -
annotationMatcher
Matches annotations that should be removed. -
parameters
private final int parametersIndices the method parameter index from which annotations should be removed, or a negative value to indicate different treatment.
-
-
Constructor Details
-
AnnotationRemoval
protected AnnotationRemoval(boolean type, ElementMatcher<? super FieldDescription.InDefinedShape> fieldMatcher, ElementMatcher<? super MethodDescription> methodMatcher, ElementMatcher<? super AnnotationDescription> annotationMatcher, int parameters) Creates a visitor for annotation removal.- Parameters:
type
-true
if annotations on the type should be removed.fieldMatcher
- Matches fields from which annotations should be removed.methodMatcher
- Matches methods from which annotations should be removed.annotationMatcher
- Matches annotations that should be removed.parameters
- Indices the method parameter index from which annotations should be removed, or a negative value to indicate different treatment.
-
-
Method Details
-
strip
Creates a visitor that removes all annotations that match the specified matcher from the instrumented type.- Parameters:
matcher
- The matcher to indicate what annotations to remove.- Returns:
- A visitor that removes the specified annotations.
-
onType
Creates a visitor that only removes annotations from the type.- Returns:
- An appropriate visitor for annotation removal.
-
onFields
Creates a visitor that only removes annotations from fields that match the specified matcher.- Parameters:
matcher
- A matcher that indicates from what fields annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onMethods
Creates a visitor that removes annotations from methods that match the specified matcher.- Parameters:
matcher
- A matcher that indicates from what methods annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onMethodsAndParameters
Creates a visitor that removes annotations from methods and their parameters that match the specified matcher.- Parameters:
matcher
- A matcher that indicates from what methods annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onMethodParameters
Creates a visitor that removes annotations from method parameters where the method matches the specified matcher.- Parameters:
matcher
- A matcher that indicates from what methods annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onMethodParameter
public AsmVisitorWrapper onMethodParameter(ElementMatcher<? super MethodDescription> matcher, int parameter) Creates a visitor that removes annotations from the method parameters with the given index where the method matches the specified matcher.- Parameters:
matcher
- A matcher that indicates from what methods annotations should be removed.parameter
- The index of the parameter of which to remove annotations.- Returns:
- An appropriate visitor for annotation removal.
-
onConstructors
Creates a visitor that removes annotations from constructors that match the specified matcher.- Parameters:
matcher
- A matcher that indicates from what constructors annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onConstructorsAndParameters
public AsmVisitorWrapper onConstructorsAndParameters(ElementMatcher<? super MethodDescription> matcher) Creates a visitor that removes annotations from constructors and their parameters that match the specified matcher.- Parameters:
matcher
- A matcher that indicates from what constructors annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onConstructorParameters
Creates a visitor that removes annotations from constructor parameters where the constructor matches the specified matcher.- Parameters:
matcher
- A matcher that indicates from what constructors annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onConstructorParameter
public AsmVisitorWrapper onConstructorParameter(ElementMatcher<? super MethodDescription> matcher, int parameter) Creates a visitor that removes annotations from the constructor parameters with the given index where the constructor matches the specified matcher.- Parameters:
matcher
- A matcher that indicates from what constructors annotations should be removed.parameter
- The index of the parameter of which to remove annotations.- Returns:
- An appropriate visitor for annotation removal.
-
onInvokables
Creates a visitor that removes annotations from constructors or methods that match the specified matcher.- Parameters:
matcher
- A matcher that indicates from what constructors or methods annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onInvokablesAndParameters
public AsmVisitorWrapper onInvokablesAndParameters(ElementMatcher<? super MethodDescription> matcher) Creates a visitor that removes annotations from constructors or methods and their parameters that match the specified matcher.- Parameters:
matcher
- A matcher that indicates from what constructors or methods annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onInvokableParameters
Creates a visitor that removes annotations from constructor or method parameters where the constructor or method matches the specified matcher.- Parameters:
matcher
- A matcher that indicates from what constructors or methods annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onInvokableParameter
public AsmVisitorWrapper onInvokableParameter(ElementMatcher<? super MethodDescription> matcher, int parameter) Creates a visitor that removes annotations from the constructor or method parameters with the given index where the constructor or method matches the specified matcher.- Parameters:
matcher
- A matcher that indicates from what constructors or methods annotations should be removed.parameter
- The index of the parameter of which to remove annotations.- Returns:
- An appropriate visitor for annotation removal.
-
wrap
public org.objectweb.asm.ClassVisitor wrap(TypeDescription instrumentedType, org.objectweb.asm.ClassVisitor classVisitor, Implementation.Context implementationContext, TypePool typePool, FieldList<FieldDescription.InDefinedShape> fields, MethodList<?> methods, int writerFlags, int readerFlags) Applies aClassVisitorWrapper
to the creation of aDynamicType
.- Parameters:
instrumentedType
- The instrumented type.classVisitor
- AClassVisitor
to become the new primary class visitor to which the createdDynamicType
is written to.implementationContext
- The implementation context of the current instrumentation.typePool
- The type pool that was provided for the class creation.fields
- The instrumented type's fields.methods
- The instrumented type's methods non-ignored declared and virtually inherited methods.writerFlags
- The ASMClassWriter
flags to consider.readerFlags
- The ASMClassReader
flags to consider.- Returns:
- A new
ClassVisitor
that usually delegates to theClassVisitor
delivered in the argument.
-