Package net.bytebuddy.asm
Class MemberSubstitution.Substitution.ForElementMatchers
- java.lang.Object
-
- net.bytebuddy.asm.MemberSubstitution.Substitution.ForElementMatchers
-
- All Implemented Interfaces:
MemberSubstitution.Substitution
- Enclosing interface:
- MemberSubstitution.Substitution
public static class MemberSubstitution.Substitution.ForElementMatchers extends java.lang.Object implements MemberSubstitution.Substitution
A substitution that uses element matchers for determining if a byte code element should be substituted.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.asm.MemberSubstitution.Substitution
MemberSubstitution.Substitution.Compound, MemberSubstitution.Substitution.ForElementMatchers, MemberSubstitution.Substitution.InvocationType, MemberSubstitution.Substitution.NoOp, MemberSubstitution.Substitution.Resolver
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ForElementMatchers(ElementMatcher<? super FieldDescription.InDefinedShape> fieldMatcher, ElementMatcher<? super MethodDescription> methodMatcher, boolean matchFieldRead, boolean matchFieldWrite, boolean includeVirtualCalls, boolean includeSuperCalls, MemberSubstitution.Substitution.Resolver resolver)
Creates a new substitution that applies element matchers to determine what byte code elements to substitute.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static MemberSubstitution.Substitution
of(ElementMatcher<? super ByteCodeElement> matcher, MemberSubstitution.Substitution.Resolver resolver)
Creates a substitution for any byte code element that matches the supplied matcher.protected static MemberSubstitution.Substitution
ofField(ElementMatcher<? super FieldDescription.InDefinedShape> matcher, boolean matchFieldRead, boolean matchFieldWrite, MemberSubstitution.Substitution.Resolver resolver)
Creates a substitution for any method that matches the supplied matcher.protected static MemberSubstitution.Substitution
ofMethod(ElementMatcher<? super MethodDescription> matcher, boolean includeVirtualCalls, boolean includeSuperCalls, MemberSubstitution.Substitution.Resolver resolver)
Creates a substitution for any method that matches the supplied matcher.MemberSubstitution.Substitution.Resolver
resolve(FieldDescription.InDefinedShape fieldDescription, boolean writeAccess)
Resolves a field access within a method body.MemberSubstitution.Substitution.Resolver
resolve(MethodDescription methodDescription, MemberSubstitution.Substitution.InvocationType invocationType)
Resolves a method invocation within a method body.
-
-
-
Constructor Detail
-
ForElementMatchers
protected ForElementMatchers(ElementMatcher<? super FieldDescription.InDefinedShape> fieldMatcher, ElementMatcher<? super MethodDescription> methodMatcher, boolean matchFieldRead, boolean matchFieldWrite, boolean includeVirtualCalls, boolean includeSuperCalls, MemberSubstitution.Substitution.Resolver resolver)
Creates a new substitution that applies element matchers to determine what byte code elements to substitute.- Parameters:
fieldMatcher
- The field matcher to determine fields to substitute.methodMatcher
- The method matcher to determine methods to substitute.matchFieldRead
-true
if field read access should be substituted.matchFieldWrite
-true
if field write access should be substituted.includeVirtualCalls
-true
if virtual method calls should be substituted.includeSuperCalls
-true
if super method calls should be substituted.resolver
- The resolver to apply on elements to substitute.
-
-
Method Detail
-
of
protected static MemberSubstitution.Substitution of(ElementMatcher<? super ByteCodeElement> matcher, MemberSubstitution.Substitution.Resolver resolver)
Creates a substitution for any byte code element that matches the supplied matcher.- Parameters:
matcher
- The matcher to determine the substituted byte code elements.resolver
- The resolver to apply on elements to substitute.- Returns:
- A substitution for all matched byte code elements.
-
ofField
protected static MemberSubstitution.Substitution ofField(ElementMatcher<? super FieldDescription.InDefinedShape> matcher, boolean matchFieldRead, boolean matchFieldWrite, MemberSubstitution.Substitution.Resolver resolver)
Creates a substitution for any method that matches the supplied matcher.- Parameters:
matcher
- The matcher to determine the substituted fields.matchFieldRead
-true
if field read access should be substituted.matchFieldWrite
-true
if field write access should be substituted.resolver
- The resolver to apply on fields to substitute.- Returns:
- A substitution for all matched fields.
-
ofMethod
protected static MemberSubstitution.Substitution ofMethod(ElementMatcher<? super MethodDescription> matcher, boolean includeVirtualCalls, boolean includeSuperCalls, MemberSubstitution.Substitution.Resolver resolver)
Creates a substitution for any method that matches the supplied matcher.- Parameters:
matcher
- The matcher to determine the substituted fields.includeVirtualCalls
-true
if virtual method calls should be substituted.includeSuperCalls
-true
if super method calls should be substituted.resolver
- The resolver to apply on fields to substitute.- Returns:
- A substitution for all matched fields.
-
resolve
public MemberSubstitution.Substitution.Resolver resolve(FieldDescription.InDefinedShape fieldDescription, boolean writeAccess)
Description copied from interface:MemberSubstitution.Substitution
Resolves a field access within a method body.- Specified by:
resolve
in interfaceMemberSubstitution.Substitution
- Parameters:
fieldDescription
- The field being accessed.writeAccess
-true
if the access is for writing to the field,false
if the field is read.- Returns:
- A resolver for the supplied field access.
-
resolve
public MemberSubstitution.Substitution.Resolver resolve(MethodDescription methodDescription, MemberSubstitution.Substitution.InvocationType invocationType)
Description copied from interface:MemberSubstitution.Substitution
Resolves a method invocation within a method body.- Specified by:
resolve
in interfaceMemberSubstitution.Substitution
- Parameters:
methodDescription
- The method being invoked.invocationType
- The method's invocation type.- Returns:
- A resolver for the supplied method invocation.
-
-