/** * Creates a member substitution that requires the resolution of all fields and methods that are referenced within a method body. Doing so, * this component raises an exception if any member cannot be resolved what makes this component unusable when facing optional types. * * @return A strict member substitution. */ public static MemberSubstitution strict() { return new MemberSubstitution(true); }
/** * Creates a member substitution that skips any unresolvable fields or methods that are referenced within a method body. Using a relaxed * member substitution, methods containing optional types are supported. In the process, it is however possible that misconfigurations * of this component remain undiscovered. * * @return A relaxed member substitution. */ public static MemberSubstitution relaxed() { return new MemberSubstitution(false); }
/** * Specifies the use of a specific method graph compiler for the resolution of virtual methods. * * @param methodGraphCompiler The method graph compiler to use. * @return A new member substitution that is equal to this but uses the specified method graph compiler. */ public MemberSubstitution with(MethodGraph.Compiler methodGraphCompiler) { return new MemberSubstitution(methodGraphCompiler, typePoolResolver, strict, replacementFactory); }
/** * Specifies a type pool resolver to be used for locating members. * * @param typePoolResolver The type pool resolver to use. * @return A new instance of this member substitution that uses the supplied type pool resolver. */ public MemberSubstitution with(TypePoolResolver typePoolResolver) { return new MemberSubstitution(methodGraphCompiler, typePoolResolver, strict, replacementFactory); }
/** * {@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))); } }
/** * {@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))); } }