/** * Creates a factory that only matches method and constructor invocations for given invocation types. * * @param matcher The matcher to identify methods and constructors for substitution. * @param includeVirtualCalls {@code true} if virtual method calls should be matched. * @param includeSuperCalls {@code true} if super method calls should be matched. * @param factory The substitution factory to apply for methods and constructors that match the specified criteria. * @return An appropriate replacement factory. */ protected static Replacement.Factory ofMethod(ElementMatcher<? super MethodDescription> matcher, boolean includeVirtualCalls, boolean includeSuperCalls, Substitution.Factory factory) { return new Factory(none(), matcher, false, false, includeVirtualCalls, includeSuperCalls, factory); }
/** * {@inheritDoc} */ public MemberSubstitution replaceWith(Substitution.Factory substitutionFactory) { return new MemberSubstitution(methodGraphCompiler, typePoolResolver, strict, new Replacement.Factory.Compound( this.replacementFactory, Replacement.ForElementMatchers.Factory.of(matcher, substitutionFactory))); } }
/** * {@inheritDoc} */ public MemberSubstitution replaceWith(Substitution.Factory substitutionFactory) { return new MemberSubstitution(methodGraphCompiler, typePoolResolver, strict, new Replacement.Factory.Compound( this.replacementFactory, Replacement.ForElementMatchers.Factory.ofField(matcher, matchRead, matchWrite, substitutionFactory))); } }
/** * Creates a factory that only matches field access for given access types. * * @param matcher The matcher to identify fields for substitution. * @param matchFieldRead {@code true} if field read access should be matched. * @param matchFieldWrite {@code true} if field write access should be matched. * @param factory The substitution factory to apply for fields that match the specified criteria. * @return An appropriate replacement factory. */ protected static Replacement.Factory ofField(ElementMatcher<? super FieldDescription.InDefinedShape> matcher, boolean matchFieldRead, boolean matchFieldWrite, Substitution.Factory factory) { return new Factory(matcher, none(), matchFieldRead, matchFieldWrite, false, false, factory); }
/** * Creates a factory for applying a substitution on all matched byte code elements for all access types. * * @param matcher The matcher to apply. * @param factory The substitution factory to create a substitution from. * @return An appropriate replacement factory for the supplied matcher and substitution factory. */ protected static Replacement.Factory of(ElementMatcher<? super ByteCodeElement> matcher, Substitution.Factory factory) { return new Factory(matcher, matcher, true, true, true, true, factory); }
/** * {@inheritDoc} */ public MemberSubstitution replaceWith(Substitution.Factory substitutionFactory) { return new MemberSubstitution(methodGraphCompiler, typePoolResolver, strict, new Replacement.Factory.Compound( this.replacementFactory, Replacement.ForElementMatchers.Factory.ofMethod(matcher, includeVirtualCalls, includeSuperCalls, substitutionFactory))); } }