@HashCodeAndEqualsPlugin.Enhance public abstract static class MemberSubstitution.WithoutSpecification extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
MemberSubstitution.WithoutSpecification.ForMatchedByteCodeElement
Describes a member substitution that requires a specification for how to replace a byte code element.
|
static class |
MemberSubstitution.WithoutSpecification.ForMatchedField
Describes a member substitution that requires a specification for how to replace a field.
|
static class |
MemberSubstitution.WithoutSpecification.ForMatchedMethod
Describes a member substitution that requires a specification for how to replace a method or constructor.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
failIfNoMatch
true if the instrumentation should fail if applied to a method without match. |
protected MethodGraph.Compiler |
methodGraphCompiler
The method graph compiler to use.
|
protected MemberSubstitution.Replacement.Factory |
replacementFactory
The replacement factory to use for creating substitutions.
|
protected boolean |
strict
true if the method processing should be strict where an exception is raised if a member cannot be found. |
protected MemberSubstitution.TypePoolResolver |
typePoolResolver
The type pool resolver to use.
|
Modifier | Constructor and Description |
---|---|
protected |
WithoutSpecification(MethodGraph.Compiler methodGraphCompiler,
MemberSubstitution.TypePoolResolver typePoolResolver,
boolean strict,
boolean failIfNoMatch,
MemberSubstitution.Replacement.Factory replacementFactory)
Creates a new member substitution that requires a specification for how to perform a substitution.
|
Modifier and Type | Method and Description |
---|---|
MemberSubstitution |
replaceWith(Field field)
Replaces any interaction with a matched byte code element by an interaction with the specified field.
|
MemberSubstitution |
replaceWith(FieldDescription fieldDescription)
Replaces any interaction with a matched byte code element by an interaction with the specified field.
|
abstract MemberSubstitution |
replaceWith(MemberSubstitution.Substitution.Factory factory)
Replaces any interaction with the supplied substitution.
|
MemberSubstitution |
replaceWith(Method method)
Replaces any interaction with a matched byte code element by an invocation of the specified method.
|
MemberSubstitution |
replaceWith(MethodDescription methodDescription)
Replaces any interaction with a matched byte code element by an invocation of the specified method.
|
MemberSubstitution |
replaceWithChain(List<? extends MemberSubstitution.Substitution.Chain.Step.Factory> steps)
Replaces the matched byte code elements with a chain of substitutions that can operate on the same values as the substituted element.
|
MemberSubstitution |
replaceWithChain(MemberSubstitution.Substitution.Chain.Step.Factory... step)
Replaces the matched byte code elements with a chain of substitutions that can operate on the same values as the substituted element.
|
MemberSubstitution |
replaceWithConstant(Object value)
Replaces any interaction with a matched byte code element with the provided compile-time constant.
|
MemberSubstitution |
replaceWithField(ElementMatcher<? super FieldDescription> matcher)
Replaces any interaction with a matched byte code element with a non-static field access on the first
parameter of the matched element.
|
MemberSubstitution |
replaceWithInstrumentedMethod()
Replaces any interaction with a matched byte code element with an invocation of the instrumented
method.
|
MemberSubstitution |
replaceWithMethod(ElementMatcher<? super MethodDescription> matcher)
Replaces any interaction with a matched byte code element with a non-static method access on the first
parameter of the matched element.
|
MemberSubstitution |
replaceWithMethod(ElementMatcher<? super MethodDescription> matcher,
MethodGraph.Compiler methodGraphCompiler)
Replaces any interaction with a matched byte code element with a non-static method access on the first
parameter of the matched element.
|
MemberSubstitution |
stub()
Subs any interaction with a matched byte code element.
|
protected final MethodGraph.Compiler methodGraphCompiler
protected final MemberSubstitution.TypePoolResolver typePoolResolver
protected final boolean strict
true
if the method processing should be strict where an exception is raised if a member cannot be found.protected final boolean failIfNoMatch
true
if the instrumentation should fail if applied to a method without match.protected final MemberSubstitution.Replacement.Factory replacementFactory
protected WithoutSpecification(MethodGraph.Compiler methodGraphCompiler, MemberSubstitution.TypePoolResolver typePoolResolver, boolean strict, boolean failIfNoMatch, MemberSubstitution.Replacement.Factory replacementFactory)
methodGraphCompiler
- The method graph compiler to use.typePoolResolver
- The type pool resolver to use.strict
- true
if the method processing should be strict where an exception is raised if a member cannot be found.failIfNoMatch
- true
if the instrumentation should fail if applied to a method without match.replacementFactory
- The replacement factory to use for creating substitutions.public MemberSubstitution stub()
null
for reference types and the specific 0
value for primitive types. Any written
value will simply be discarded.public MemberSubstitution replaceWithConstant(Object value)
value
- The compile-time constant to set.public MemberSubstitution replaceWith(Field field)
Replaces any interaction with a matched byte code element by an interaction with the specified field. If a field is replacing a method or constructor invocation, it is treated as if it was a field getter or setter respectively.
A replacement can only be applied if the field is compatible to the original byte code element, i.e. consumes an
instance of the declaring type if it is not static
as an argument and consumes or produces an instance of
the field's type.
field
- The field to access instead of interacting with any of the matched byte code elements.public MemberSubstitution replaceWith(FieldDescription fieldDescription)
Replaces any interaction with a matched byte code element by an interaction with the specified field. If a field is replacing a method or constructor invocation, it is treated as if it was a field getter or setter respectively.
A replacement can only be applied if the field is compatible to the original byte code element, i.e. consumes an
instance of the declaring type if it is not static
as an argument and consumes or produces an instance of
the field's type.
fieldDescription
- The field to access instead of interacting with any of the matched byte code elements.public MemberSubstitution replaceWithField(ElementMatcher<? super FieldDescription> matcher)
matcher
- A matcher for locating a field on the original interaction's receiver type.public MemberSubstitution replaceWith(Method method)
Replaces any interaction with a matched byte code element by an invocation of the specified method. If a method is replacing a field access, it is treated as if it was replacing an invocation of the field's getter or setter respectively.
A replacement can only be applied if the method is compatible to the original byte code element, i.e. consumes compatible
arguments and returns a compatible value. If the method is not static
, it is treated as if this
was an implicit
first argument.
method
- The method to invoke instead of interacting with any of the matched byte code elements.public MemberSubstitution replaceWith(MethodDescription methodDescription)
Replaces any interaction with a matched byte code element by an invocation of the specified method. If a method is replacing a field access, it is treated as if it was replacing an invocation of the field's getter or setter respectively.
A replacement can only be applied if the method is compatible to the original byte code element, i.e. consumes compatible
arguments and returns a compatible value. If the method is not static
, it is treated as if this
was an implicit
first argument.
Important: It is not allowed to specify a constructor or the static type initializer as a replacement.
methodDescription
- The method to invoke instead of interacting with any of the matched byte code elements.public MemberSubstitution replaceWithMethod(ElementMatcher<? super MethodDescription> matcher)
matcher
- A matcher for locating a method on the original interaction's receiver type.public MemberSubstitution replaceWithMethod(ElementMatcher<? super MethodDescription> matcher, MethodGraph.Compiler methodGraphCompiler)
matcher
- A matcher for locating a method on the original interaction's receiver type.methodGraphCompiler
- The method graph compiler to use for locating a method.public MemberSubstitution replaceWithInstrumentedMethod()
public MemberSubstitution replaceWithChain(MemberSubstitution.Substitution.Chain.Step.Factory... step)
step
- The steps to apply for a substitution.public MemberSubstitution replaceWithChain(List<? extends MemberSubstitution.Substitution.Chain.Step.Factory> steps)
steps
- The steps to apply for a substitution.public abstract MemberSubstitution replaceWith(MemberSubstitution.Substitution.Factory factory)
factory
- The substitution factory to use for creating the applied substitution.Copyright © 2014–2024. All rights reserved.