@HashCodeAndEqualsPlugin.Enhance public class MemberRemoval extends AsmVisitorWrapper.AbstractBase
A visitor wrapper that removes fields or methods that match a given ElementMatcher
.
Important: This matcher is not capable of removing synthetic bridge methods which will be retained if they are declared by the same class. As bridge methods only invoke an overridden method, the dispatch should however not be influenced by their retention.
Important: The removal of the method is not reflected in the created DynamicType
's
type description of the instrumented type.
Modifier and Type | Class and Description |
---|---|
protected static class |
MemberRemoval.MemberRemovingClassVisitor
A class visitor that removes members based on element matchers.
|
AsmVisitorWrapper.AbstractBase, AsmVisitorWrapper.Compound, AsmVisitorWrapper.ForDeclaredFields, AsmVisitorWrapper.ForDeclaredMethods, AsmVisitorWrapper.NoOp
NO_FLAGS
Modifier | Constructor and Description |
---|---|
|
MemberRemoval()
Creates a new member removal instance that does not specify the removal of any methods.
|
protected |
MemberRemoval(ElementMatcher.Junction<FieldDescription.InDefinedShape> fieldMatcher,
ElementMatcher.Junction<MethodDescription> methodMatcher)
Creates a new member removal instance.
|
Modifier and Type | Method and Description |
---|---|
MemberRemoval |
stripConstructors(ElementMatcher<? super MethodDescription> matcher)
Specifies that any constructor that matches the specified matcher should be removed.
|
MemberRemoval |
stripFields(ElementMatcher<? super FieldDescription.InDefinedShape> matcher)
Specifies that any field that matches the specified matcher should be removed.
|
MemberRemoval |
stripInvokables(ElementMatcher<? super MethodDescription> matcher)
Specifies that any method or constructor that matches the specified matcher should be removed.
|
MemberRemoval |
stripMethods(ElementMatcher<? super MethodDescription> matcher)
Specifies that any method that matches the specified matcher should be removed.
|
ClassVisitor |
wrap(TypeDescription instrumentedType,
ClassVisitor classVisitor,
Implementation.Context implementationContext,
TypePool typePool,
FieldList<FieldDescription.InDefinedShape> fields,
MethodList<?> methods,
int writerFlags,
int readerFlags)
Applies a
ClassVisitorWrapper to the creation of a DynamicType . |
mergeReader, mergeWriter
public MemberRemoval()
protected MemberRemoval(ElementMatcher.Junction<FieldDescription.InDefinedShape> fieldMatcher, ElementMatcher.Junction<MethodDescription> methodMatcher)
fieldMatcher
- The matcher that decides upon field removal.methodMatcher
- The matcher that decides upon field removal.public MemberRemoval stripFields(ElementMatcher<? super FieldDescription.InDefinedShape> matcher)
matcher
- The matcher that decides upon field removal.public MemberRemoval stripMethods(ElementMatcher<? super MethodDescription> matcher)
matcher
- The matcher that decides upon method removal.public MemberRemoval stripConstructors(ElementMatcher<? super MethodDescription> matcher)
matcher
- The matcher that decides upon constructor removal.public MemberRemoval stripInvokables(ElementMatcher<? super MethodDescription> matcher)
matcher
- The matcher that decides upon method and constructor removal.public ClassVisitor wrap(TypeDescription instrumentedType, ClassVisitor classVisitor, Implementation.Context implementationContext, TypePool typePool, FieldList<FieldDescription.InDefinedShape> fields, MethodList<?> methods, int writerFlags, int readerFlags)
ClassVisitorWrapper
to the creation of a DynamicType
.instrumentedType
- The instrumented type.classVisitor
- A ClassVisitor
to become the new primary class visitor to which the created
DynamicType
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 ASM ClassWriter
flags to consider.readerFlags
- The ASM ClassReader
flags to consider.ClassVisitor
that usually delegates to the ClassVisitor
delivered in the argument.Copyright © 2014–2020. All rights reserved.