Package net.bytebuddy.asm
Class MemberSubstitution.Replacement.ForElementMatchers.Factory
- java.lang.Object
-
- net.bytebuddy.asm.MemberSubstitution.Replacement.ForElementMatchers.Factory
-
- All Implemented Interfaces:
MemberSubstitution.Replacement.Factory
- Enclosing class:
- MemberSubstitution.Replacement.ForElementMatchers
@Enhance protected static class MemberSubstitution.Replacement.ForElementMatchers.Factory extends java.lang.Object implements MemberSubstitution.Replacement.Factory
A factory for creating a replacement that chooses members based on a row of element matchers.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.asm.MemberSubstitution.Replacement.Factory
MemberSubstitution.Replacement.Factory.Compound
-
-
Field Summary
Fields Modifier and Type Field Description private ElementMatcher<? super FieldDescription>fieldMatcherThe field matcher to consider when discovering fields.private booleanincludeSuperCallstrueif super method calls should be matched.private booleanincludeVirtualCallstrueif virtual method calls should be matched.private booleanmatchFieldReadtrueif field reading access should be matched.private booleanmatchFieldWritetrueif field writing access should be matched.private ElementMatcher<? super MethodDescription>methodMatcherThe method matcher to consider when discovering methods.private MemberSubstitution.Substitution.Factory<? super MemberSubstitution.Target.ForMember>substitutionFactoryThe substitution factory to create a substitution from.
-
Constructor Summary
Constructors Modifier Constructor Description protectedFactory(ElementMatcher<? super FieldDescription> fieldMatcher, ElementMatcher<? super MethodDescription> methodMatcher, boolean matchFieldRead, boolean matchFieldWrite, boolean includeVirtualCalls, boolean includeSuperCalls, MemberSubstitution.Substitution.Factory<? super MemberSubstitution.Target.ForMember> substitutionFactory)Creates a new replacement that triggers a substitution based on a row of matchers.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MemberSubstitution.Replacementmake(TypeDescription instrumentedType, MethodDescription instrumentedMethod, TypePool typePool)Creates a replacement for an instrumented method.protected static MemberSubstitution.Replacement.Factoryof(ElementMatcher<? super ByteCodeElement.Member> matcher, MemberSubstitution.Substitution.Factory<? super MemberSubstitution.Target.ForMember> factory)Creates a factory for applying a substitution on all matched byte code elements for all access types.protected static MemberSubstitution.Replacement.FactoryofField(ElementMatcher<? super FieldDescription> matcher, boolean matchFieldRead, boolean matchFieldWrite, MemberSubstitution.Substitution.Factory<? super MemberSubstitution.Target.ForMember> factory)Creates a factory that only matches field access for given access types.protected static MemberSubstitution.Replacement.FactoryofMethod(ElementMatcher<? super MethodDescription> matcher, boolean includeVirtualCalls, boolean includeSuperCalls, MemberSubstitution.Substitution.Factory<? super MemberSubstitution.Target.ForMember> factory)Creates a factory that only matches method and constructor invocations for given invocation types.
-
-
-
Field Detail
-
fieldMatcher
private final ElementMatcher<? super FieldDescription> fieldMatcher
The field matcher to consider when discovering fields.
-
methodMatcher
private final ElementMatcher<? super MethodDescription> methodMatcher
The method matcher to consider when discovering methods.
-
matchFieldRead
private final boolean matchFieldRead
trueif field reading access should be matched.
-
matchFieldWrite
private final boolean matchFieldWrite
trueif field writing access should be matched.
-
includeVirtualCalls
private final boolean includeVirtualCalls
trueif virtual method calls should be matched.
-
includeSuperCalls
private final boolean includeSuperCalls
trueif super method calls should be matched.
-
substitutionFactory
private final MemberSubstitution.Substitution.Factory<? super MemberSubstitution.Target.ForMember> substitutionFactory
The substitution factory to create a substitution from.
-
-
Constructor Detail
-
Factory
protected Factory(ElementMatcher<? super FieldDescription> fieldMatcher, ElementMatcher<? super MethodDescription> methodMatcher, boolean matchFieldRead, boolean matchFieldWrite, boolean includeVirtualCalls, boolean includeSuperCalls, MemberSubstitution.Substitution.Factory<? super MemberSubstitution.Target.ForMember> substitutionFactory)
Creates a new replacement that triggers a substitution based on a row of matchers.- Parameters:
fieldMatcher- The field matcher to consider when discovering fields.methodMatcher- The method matcher to consider when discovering methods.matchFieldRead-trueif field reading access should be matched.matchFieldWrite-trueif field writing access should be matched.includeVirtualCalls-trueif virtual method calls should be matched.includeSuperCalls-trueif super method calls should be matched.substitutionFactory- The substitution factory to create a substitution from.
-
-
Method Detail
-
of
protected static MemberSubstitution.Replacement.Factory of(ElementMatcher<? super ByteCodeElement.Member> matcher, MemberSubstitution.Substitution.Factory<? super MemberSubstitution.Target.ForMember> factory)
Creates a factory for applying a substitution on all matched byte code elements for all access types.- Parameters:
matcher- The matcher to apply.factory- The substitution factory to create a substitution from.- Returns:
- An appropriate replacement factory for the supplied matcher and substitution factory.
-
ofField
protected static MemberSubstitution.Replacement.Factory ofField(ElementMatcher<? super FieldDescription> matcher, boolean matchFieldRead, boolean matchFieldWrite, MemberSubstitution.Substitution.Factory<? super MemberSubstitution.Target.ForMember> factory)
Creates a factory that only matches field access for given access types.- Parameters:
matcher- The matcher to identify fields for substitution.matchFieldRead-trueif field read access should be matched.matchFieldWrite-trueif field write access should be matched.factory- The substitution factory to apply for fields that match the specified criteria.- Returns:
- An appropriate replacement factory.
-
ofMethod
protected static MemberSubstitution.Replacement.Factory ofMethod(ElementMatcher<? super MethodDescription> matcher, boolean includeVirtualCalls, boolean includeSuperCalls, MemberSubstitution.Substitution.Factory<? super MemberSubstitution.Target.ForMember> factory)
Creates a factory that only matches method and constructor invocations for given invocation types.- Parameters:
matcher- The matcher to identify methods and constructors for substitution.includeVirtualCalls-trueif virtual method calls should be matched.includeSuperCalls-trueif super method calls should be matched.factory- The substitution factory to apply for methods and constructors that match the specified criteria.- Returns:
- An appropriate replacement factory.
-
make
public MemberSubstitution.Replacement make(TypeDescription instrumentedType, MethodDescription instrumentedMethod, TypePool typePool)
Creates a replacement for an instrumented method.- Specified by:
makein interfaceMemberSubstitution.Replacement.Factory- Parameters:
instrumentedType- The instrumented type.instrumentedMethod- The instrumented method.typePool- The type pool being used within the member substitution being applied.- Returns:
- A replacement to use within the supplied instrumented method.
-
-