Package net.bytebuddy.asm
Class AsmVisitorWrapper.ForDeclaredFields
java.lang.Object
net.bytebuddy.asm.AsmVisitorWrapper.AbstractBase
net.bytebuddy.asm.AsmVisitorWrapper.ForDeclaredFields
- All Implemented Interfaces:
AsmVisitorWrapper
- Enclosing interface:
AsmVisitorWrapper
@Enhance
public static class AsmVisitorWrapper.ForDeclaredFields
extends AsmVisitorWrapper.AbstractBase
An ASM visitor wrapper that allows to wrap declared fields of the instrumented type with a
AsmVisitorWrapper.ForDeclaredFields.FieldVisitorWrapper
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
A class visitor that applies the outer ASM visitor for identifying declared fields.protected static class
An entry describing a field visitor wrapper paired with a matcher for fields to be wrapped.static interface
A field visitor wrapper that allows for wrapping aFieldVisitor
defining a declared field.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 List
<AsmVisitorWrapper.ForDeclaredFields.Entry> The list of entries that describe matched fields in their application order.Fields inherited from interface net.bytebuddy.asm.AsmVisitorWrapper
NO_FLAGS
-
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates a new visitor wrapper for declared fields.protected
Creates a new visitor wrapper for declared fields. -
Method Summary
Modifier and TypeMethodDescriptionfield
(ElementMatcher<? super FieldDescription.InDefinedShape> matcher, List<? extends AsmVisitorWrapper.ForDeclaredFields.FieldVisitorWrapper> fieldVisitorWrappers) Defines a new field visitor wrapper to be applied if the given field matcher is matched.field
(ElementMatcher<? super FieldDescription.InDefinedShape> matcher, AsmVisitorWrapper.ForDeclaredFields.FieldVisitorWrapper... fieldVisitorWrapper) Defines a new field visitor wrapper to be applied if the given field matcher is matched.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
-
entries
The list of entries that describe matched fields in their application order.
-
-
Constructor Details
-
ForDeclaredFields
public ForDeclaredFields()Creates a new visitor wrapper for declared fields. -
ForDeclaredFields
Creates a new visitor wrapper for declared fields.- Parameters:
entries
- The list of entries that describe matched fields in their application order.
-
-
Method Details
-
field
public AsmVisitorWrapper.ForDeclaredFields field(ElementMatcher<? super FieldDescription.InDefinedShape> matcher, AsmVisitorWrapper.ForDeclaredFields.FieldVisitorWrapper... fieldVisitorWrapper) Defines a new field visitor wrapper to be applied if the given field matcher is matched. Previously defined entries are applied before the given matcher is applied.- Parameters:
matcher
- The matcher to identify fields to be wrapped.fieldVisitorWrapper
- The field visitor wrapper to be applied if the given matcher is matched.- Returns:
- A new ASM visitor wrapper that applied the given field visitor wrapper if the supplied matcher is matched.
-
field
public AsmVisitorWrapper.ForDeclaredFields field(ElementMatcher<? super FieldDescription.InDefinedShape> matcher, List<? extends AsmVisitorWrapper.ForDeclaredFields.FieldVisitorWrapper> fieldVisitorWrappers) Defines a new field visitor wrapper to be applied if the given field matcher is matched. Previously defined entries are applied before the given matcher is applied.- Parameters:
matcher
- The matcher to identify fields to be wrapped.fieldVisitorWrappers
- The field visitor wrapper to be applied if the given matcher is matched.- Returns:
- A new ASM visitor wrapper that applied the given field visitor wrapper if the supplied matcher is matched.
-
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.
-