Class MemberSubstitution.WithoutSpecification.ForMatchedField
java.lang.Object
net.bytebuddy.asm.MemberSubstitution.WithoutSpecification<MemberSubstitution.Target.ForMember>
net.bytebuddy.asm.MemberSubstitution.WithoutSpecification.ForMatchedField
- Enclosing class:
MemberSubstitution.WithoutSpecification<T extends MemberSubstitution.Target>
@Enhance
public static class MemberSubstitution.WithoutSpecification.ForMatchedField
extends MemberSubstitution.WithoutSpecification<MemberSubstitution.Target.ForMember>
Describes a member substitution that requires a specification for how to replace a field.
-
Nested Class Summary
Nested classes/interfaces inherited from class MemberSubstitution.WithoutSpecification
MemberSubstitution.WithoutSpecification.ForMatchedByteCodeElement, MemberSubstitution.WithoutSpecification.ForMatchedDynamicInvocation, MemberSubstitution.WithoutSpecification.ForMatchedField, MemberSubstitution.WithoutSpecification.ForMatchedMethod -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ElementMatcher<? super FieldDescription> A matcher for any field that should be substituted.private final booleantrueif read access to a field should be substituted.private final booleantrueif write access to a field should be substituted.Fields inherited from class MemberSubstitution.WithoutSpecification
failIfNoMatch, methodGraphCompiler, replacementFactory, strict, typePoolResolver -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedForMatchedField(MethodGraph.Compiler methodGraphCompiler, MemberSubstitution.TypePoolResolver typePoolResolver, boolean strict, boolean failIfNoMatch, MemberSubstitution.Replacement.Factory replacementFactory, ElementMatcher<? super FieldDescription> matcher) Creates a new member substitution for a matched field that requires a specification for how to perform a substitution.protectedForMatchedField(MethodGraph.Compiler methodGraphCompiler, MemberSubstitution.TypePoolResolver typePoolResolver, boolean strict, boolean failIfNoMatch, MemberSubstitution.Replacement.Factory replacementFactory, ElementMatcher<? super FieldDescription> matcher, boolean matchRead, boolean matchWrite) Creates a new member substitution for a matched field that requires a specification for how to perform a substitution. -
Method Summary
Modifier and TypeMethodDescriptiononRead()When invoked, only read access of the previously matched field is substituted.onWrite()When invoked, only write access of the previously matched field is substituted.replaceWith(MemberSubstitution.Substitution.Factory<? super MemberSubstitution.Target.ForMember> substitutionFactory) Replaces any interaction with the supplied substitution.
-
Field Details
-
matcher
A matcher for any field that should be substituted. -
matchRead
private final boolean matchReadtrueif read access to a field should be substituted. -
matchWrite
private final boolean matchWritetrueif write access to a field should be substituted.
-
-
Constructor Details
-
ForMatchedField
protected ForMatchedField(MethodGraph.Compiler methodGraphCompiler, MemberSubstitution.TypePoolResolver typePoolResolver, boolean strict, boolean failIfNoMatch, MemberSubstitution.Replacement.Factory replacementFactory, ElementMatcher<? super FieldDescription> matcher) Creates a new member substitution for a matched field that requires a specification for how to perform a substitution.- Parameters:
methodGraphCompiler- The method graph compiler to use.typePoolResolver- The type pool resolver to use.strict-trueif the method processing should be strict where an exception is raised if a member cannot be found.failIfNoMatch-trueif the instrumentation should fail if applied to a method without match.replacementFactory- The replacement factory to use.matcher- A matcher for any field that should be substituted.
-
ForMatchedField
protected ForMatchedField(MethodGraph.Compiler methodGraphCompiler, MemberSubstitution.TypePoolResolver typePoolResolver, boolean strict, boolean failIfNoMatch, MemberSubstitution.Replacement.Factory replacementFactory, ElementMatcher<? super FieldDescription> matcher, boolean matchRead, boolean matchWrite) Creates a new member substitution for a matched field that requires a specification for how to perform a substitution.- Parameters:
methodGraphCompiler- The method graph compiler to use.typePoolResolver- The type pool resolver to use.strict-trueif the method processing should be strict where an exception is raised if a member cannot be found.failIfNoMatch-trueif the instrumentation should fail if applied to a method without match.replacementFactory- The replacement factory to use.matcher- A matcher for any field that should be substituted.matchRead-trueif read access to a field should be substituted.matchWrite-trueif write access to a field should be substituted.
-
-
Method Details
-
onRead
When invoked, only read access of the previously matched field is substituted.- Returns:
- This instance with the limitation that only read access to the matched field is substituted.
-
onWrite
When invoked, only write access of the previously matched field is substituted.- Returns:
- This instance with the limitation that only write access to the matched field is substituted.
-
replaceWith
public MemberSubstitution replaceWith(MemberSubstitution.Substitution.Factory<? super MemberSubstitution.Target.ForMember> substitutionFactory) Replaces any interaction with the supplied substitution.- Specified by:
replaceWithin classMemberSubstitution.WithoutSpecification<MemberSubstitution.Target.ForMember>- Parameters:
substitutionFactory- The substitution factory to use for creating the applied substitution.- Returns:
- A member substitution that replaces any matched byte code element with the supplied substitution.
-