Package net.bytebuddy.implementation
Class MethodDelegation.WithCustomProperties
- java.lang.Object
-
- net.bytebuddy.implementation.MethodDelegation.WithCustomProperties
-
- Enclosing class:
- MethodDelegation
@Enhance public static class MethodDelegation.WithCustomProperties extends java.lang.Object
AMethodDelegation
with custom configuration.
-
-
Field Summary
Fields Modifier and Type Field Description private MethodDelegationBinder.AmbiguityResolver
ambiguityResolver
The ambiguity resolver to use.private MethodDelegationBinder.BindingResolver
bindingResolver
The binding resolver being used to select the relevant method binding.private ElementMatcher<? super MethodDescription>
matcher
The matcher to use for filtering relevant methods.private java.util.List<TargetMethodAnnotationDrivenBinder.ParameterBinder<?>>
parameterBinders
The parameter binders to use.
-
Constructor Summary
Constructors Modifier Constructor Description protected
WithCustomProperties(MethodDelegationBinder.AmbiguityResolver ambiguityResolver, java.util.List<TargetMethodAnnotationDrivenBinder.ParameterBinder<?>> parameterBinders)
Creates a new method delegation with custom properties that does not filter any methods.private
WithCustomProperties(MethodDelegationBinder.AmbiguityResolver ambiguityResolver, java.util.List<TargetMethodAnnotationDrivenBinder.ParameterBinder<?>> parameterBinders, MethodDelegationBinder.BindingResolver bindingResolver, ElementMatcher<? super MethodDescription> matcher)
Creates a new method delegation with custom properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MethodDelegation.WithCustomProperties
filter(ElementMatcher<? super MethodDescription> matcher)
Configures this method delegation to only consider methods or constructors as a delegation target if they match the supplied matcher.MethodDelegation
to(java.lang.Class<?> type)
Delegates any intercepted method to invoke astatic
method that is declared by the supplied type.MethodDelegation
to(java.lang.Object target)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types.MethodDelegation
to(java.lang.Object target, java.lang.reflect.Type type)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types.MethodDelegation
to(java.lang.Object target, java.lang.reflect.Type type, java.lang.String fieldName)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types.MethodDelegation
to(java.lang.Object target, java.lang.reflect.Type type, java.lang.String fieldName, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types.MethodDelegation
to(java.lang.Object target, java.lang.reflect.Type type, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types.MethodDelegation
to(java.lang.Object target, java.lang.String fieldName)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types.MethodDelegation
to(java.lang.Object target, java.lang.String fieldName, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types.MethodDelegation
to(java.lang.Object target, TypeDefinition typeDefinition)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types.MethodDelegation
to(java.lang.Object target, TypeDefinition typeDefinition, java.lang.String fieldName)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types.MethodDelegation
to(java.lang.Object target, TypeDefinition typeDefinition, java.lang.String fieldName, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types.MethodDelegation
to(java.lang.Object target, TypeDefinition typeDefinition, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types.MethodDelegation
to(java.lang.Object target, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types.MethodDelegation
to(TypeDescription typeDescription)
Delegates any intercepted method to invoke astatic
method that is declared by the supplied type.MethodDelegation
toConstructor(java.lang.Class<?> type)
Delegates any intercepted method to invoke a constructor of the supplied type.MethodDelegation
toConstructor(TypeDescription typeDescription)
Delegates any intercepted method to invoke a constructor of the supplied type.MethodDelegation
toField(java.lang.String name)
Delegates any intercepted method to invoke a non-static
method on the instance of the supplied field.MethodDelegation
toField(java.lang.String name, FieldLocator.Factory fieldLocatorFactory)
Delegates any intercepted method to invoke a non-static
method on the instance of the supplied field.MethodDelegation
toField(java.lang.String name, FieldLocator.Factory fieldLocatorFactory, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a non-static
method on the instance of the supplied field.MethodDelegation
toField(java.lang.String name, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a non-static
method on the instance of the supplied field.MethodDelegation
toMethodReturnOf(java.lang.String name)
Delegates any intercepted method to invoke a method on an instance that is returned by a parameterless method of the given name.MethodDelegation
toMethodReturnOf(java.lang.String name, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a method on an instance that is returned by a parameterless method of the given name.MethodDelegation.WithCustomProperties
withBinders(java.util.List<? extends TargetMethodAnnotationDrivenBinder.ParameterBinder<?>> parameterBinders)
Configures this method delegation to use the supplied parameter binders when deciding what value to assign to a parameter of a delegation target.MethodDelegation.WithCustomProperties
withBinders(TargetMethodAnnotationDrivenBinder.ParameterBinder<?>... parameterBinder)
Configures this method delegation to use the supplied parameter binders when deciding what value to assign to a parameter of a delegation target.MethodDelegation.WithCustomProperties
withBindingResolver(MethodDelegationBinder.BindingResolver bindingResolver)
Configures a custom binding resolver which is responsible for choosing a method binding among multiple candidates.MethodDelegation.WithCustomProperties
withResolvers(java.util.List<? extends MethodDelegationBinder.AmbiguityResolver> ambiguityResolvers)
Configures this method delegation to use the supplied ambiguity resolvers when deciding which out of two ore more legal delegation targets should be considered.MethodDelegation.WithCustomProperties
withResolvers(MethodDelegationBinder.AmbiguityResolver... ambiguityResolver)
Configures this method delegation to use the supplied ambiguity resolvers when deciding which out of two ore more legal delegation targets should be considered.
-
-
-
Field Detail
-
ambiguityResolver
private final MethodDelegationBinder.AmbiguityResolver ambiguityResolver
The ambiguity resolver to use.
-
parameterBinders
private final java.util.List<TargetMethodAnnotationDrivenBinder.ParameterBinder<?>> parameterBinders
The parameter binders to use.
-
bindingResolver
private final MethodDelegationBinder.BindingResolver bindingResolver
The binding resolver being used to select the relevant method binding.
-
matcher
private final ElementMatcher<? super MethodDescription> matcher
The matcher to use for filtering relevant methods.
-
-
Constructor Detail
-
WithCustomProperties
protected WithCustomProperties(MethodDelegationBinder.AmbiguityResolver ambiguityResolver, java.util.List<TargetMethodAnnotationDrivenBinder.ParameterBinder<?>> parameterBinders)
Creates a new method delegation with custom properties that does not filter any methods.- Parameters:
ambiguityResolver
- The ambiguity resolver to use.parameterBinders
- The parameter binders to use.
-
WithCustomProperties
private WithCustomProperties(MethodDelegationBinder.AmbiguityResolver ambiguityResolver, java.util.List<TargetMethodAnnotationDrivenBinder.ParameterBinder<?>> parameterBinders, MethodDelegationBinder.BindingResolver bindingResolver, ElementMatcher<? super MethodDescription> matcher)
Creates a new method delegation with custom properties.- Parameters:
ambiguityResolver
- The ambiguity resolver to use.parameterBinders
- The parameter binders to use.bindingResolver
- The binding resolver being used to select the relevant method binding.matcher
- The matcher to use for filtering relevant methods.
-
-
Method Detail
-
withResolvers
public MethodDelegation.WithCustomProperties withResolvers(MethodDelegationBinder.AmbiguityResolver... ambiguityResolver)
Configures this method delegation to use the supplied ambiguity resolvers when deciding which out of two ore more legal delegation targets should be considered.- Parameters:
ambiguityResolver
- The ambiguity resolvers to use in their application order.- Returns:
- A new delegation configuration which also applies the supplied ambiguity resolvers.
-
withResolvers
public MethodDelegation.WithCustomProperties withResolvers(java.util.List<? extends MethodDelegationBinder.AmbiguityResolver> ambiguityResolvers)
Configures this method delegation to use the supplied ambiguity resolvers when deciding which out of two ore more legal delegation targets should be considered.- Parameters:
ambiguityResolvers
- The ambiguity resolvers to use in their application order.- Returns:
- A new delegation configuration which also applies the supplied ambiguity resolvers.
-
withBinders
public MethodDelegation.WithCustomProperties withBinders(TargetMethodAnnotationDrivenBinder.ParameterBinder<?>... parameterBinder)
Configures this method delegation to use the supplied parameter binders when deciding what value to assign to a parameter of a delegation target.- Parameters:
parameterBinder
- The parameter binders to use.- Returns:
- A new delegation configuration which also applies the supplied parameter binders.
-
withBinders
public MethodDelegation.WithCustomProperties withBinders(java.util.List<? extends TargetMethodAnnotationDrivenBinder.ParameterBinder<?>> parameterBinders)
Configures this method delegation to use the supplied parameter binders when deciding what value to assign to a parameter of a delegation target.- Parameters:
parameterBinders
- The parameter binders to use.- Returns:
- A new delegation configuration which also applies the supplied parameter binders.
-
withBindingResolver
public MethodDelegation.WithCustomProperties withBindingResolver(MethodDelegationBinder.BindingResolver bindingResolver)
Configures a custom binding resolver which is responsible for choosing a method binding among multiple candidates. Configuring a resolver overrides any previous configuration.- Parameters:
bindingResolver
- The binding resolver being used to select the relevant method binding.- Returns:
- A new delegation configuration which applies the supplied binding resolver.
-
filter
public MethodDelegation.WithCustomProperties filter(ElementMatcher<? super MethodDescription> matcher)
Configures this method delegation to only consider methods or constructors as a delegation target if they match the supplied matcher.- Parameters:
matcher
- The matcher any delegation target needs to match in order to be considered a for delegation.- Returns:
- A new delegation configuration which only considers methods for delegation if they match the supplied matcher.
-
to
public MethodDelegation to(java.lang.Class<?> type)
Delegates any intercepted method to invoke astatic
method that is declared by the supplied type. To be considered a valid delegation target, the target method must be visible and accessible to the instrumented type. This is the case if the target type is either public or in the same package as the instrumented type and if the target method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the interception is targeting the instrumented type.- Parameters:
type
- The target type for the delegation.- Returns:
- A method delegation that redirects method calls to a static method of the supplied type.
-
to
public MethodDelegation to(TypeDescription typeDescription)
Delegates any intercepted method to invoke astatic
method that is declared by the supplied type. To be considered a valid delegation target, the target method must be visible and accessible to the instrumented type. This is the case if the target type is either public or in the same package as the instrumented type and if the target method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
typeDescription
- The target type for the delegation.- Returns:
- A method delegation that redirects method calls to a static method of the supplied type.
-
to
public MethodDelegation to(java.lang.Object target)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
target
- The target instance for the delegation.- Returns:
- A method delegation that redirects method calls to a static method of the supplied type.
-
to
public MethodDelegation to(java.lang.Object target, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
target
- The target instance for the delegation.methodGraphCompiler
- The method graph compiler to use.- Returns:
- A method delegation that redirects method calls to a static method of the supplied type.
-
to
public MethodDelegation to(java.lang.Object target, java.lang.String fieldName)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
target
- The target instance for the delegation.fieldName
- The name of the field that is holding thetarget
instance.- Returns:
- A method delegation that redirects method calls to a static method of the supplied type.
-
to
public MethodDelegation to(java.lang.Object target, java.lang.String fieldName, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
target
- The target instance for the delegation.fieldName
- The name of the field that is holding thetarget
instance.methodGraphCompiler
- The method graph compiler to use.- Returns:
- A method delegation that redirects method calls to a static method of the supplied type.
-
to
public MethodDelegation to(java.lang.Object target, java.lang.reflect.Type type)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
target
- The target instance for the delegation.type
- The most specific type of whichtarget
should be considered. Must be a super type of the target's actual type.- Returns:
- A method delegation that redirects method calls to a static method of the supplied type.
-
to
public MethodDelegation to(java.lang.Object target, java.lang.reflect.Type type, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
target
- The target instance for the delegation.type
- The most specific type of whichtarget
should be considered. Must be a super type of the target's actual type.methodGraphCompiler
- The method graph compiler to use.- Returns:
- A method delegation that redirects method calls to a static method of the supplied type.
-
to
public MethodDelegation to(java.lang.Object target, java.lang.reflect.Type type, java.lang.String fieldName)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
target
- The target instance for the delegation.type
- The most specific type of whichtarget
should be considered. Must be a super type of the target's actual type.fieldName
- The name of the field that is holding thetarget
instance.- Returns:
- A method delegation that redirects method calls to a static method of the supplied type.
-
to
public MethodDelegation to(java.lang.Object target, java.lang.reflect.Type type, java.lang.String fieldName, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
target
- The target instance for the delegation.type
- The most specific type of whichtarget
should be considered. Must be a super type of the target's actual type.fieldName
- The name of the field that is holding thetarget
instance.methodGraphCompiler
- The method graph compiler to use.- Returns:
- A method delegation that redirects method calls to a static method of the supplied type.
-
to
public MethodDelegation to(java.lang.Object target, TypeDefinition typeDefinition)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
target
- The target instance for the delegation.typeDefinition
- The most specific type of whichtarget
should be considered. Must be a super type of the target's actual type.- Returns:
- A method delegation that redirects method calls to a static method of the supplied type.
-
to
public MethodDelegation to(java.lang.Object target, TypeDefinition typeDefinition, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
target
- The target instance for the delegation.typeDefinition
- The most specific type of whichtarget
should be considered. Must be a super type of the target's actual type.methodGraphCompiler
- The method graph compiler to use.- Returns:
- A method delegation that redirects method calls to a static method of the supplied type.
-
to
public MethodDelegation to(java.lang.Object target, TypeDefinition typeDefinition, java.lang.String fieldName)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
target
- The target instance for the delegation.typeDefinition
- The most specific type of whichtarget
should be considered. Must be a super type of the target's actual type.fieldName
- The name of the field that is holding thetarget
instance.- Returns:
- A method delegation that redirects method calls to a static method of the supplied type.
-
to
public MethodDelegation to(java.lang.Object target, TypeDefinition typeDefinition, java.lang.String fieldName, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a non-static
method that is declared by the supplied type's instance or any of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
target
- The target instance for the delegation.typeDefinition
- The most specific type of whichtarget
should be considered. Must be a super type of the target's actual type.fieldName
- The name of the field that is holding thetarget
instance.methodGraphCompiler
- The method graph compiler to use.- Returns:
- A method delegation that redirects method calls to a static method of the supplied type.
-
toConstructor
public MethodDelegation toConstructor(java.lang.Class<?> type)
Delegates any intercepted method to invoke a constructor of the supplied type. To be considered a valid delegation target, a constructor must be visible and accessible to the instrumented type. This is the case if the constructor's declaring type is either public or in the same package as the instrumented type and if the constructor is either public or non-private and in the same package as the instrumented type. Private constructors can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
type
- The type to construct.- Returns:
- A delegation that redirects method calls to a constructor of the supplied type.
-
toConstructor
public MethodDelegation toConstructor(TypeDescription typeDescription)
Delegates any intercepted method to invoke a constructor of the supplied type. To be considered a valid delegation target, a constructor must be visible and accessible to the instrumented type. This is the case if the constructor's declaring type is either public or in the same package as the instrumented type and if the constructor is either public or non-private and in the same package as the instrumented type. Private constructors can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
typeDescription
- The type to construct.- Returns:
- A delegation that redirects method calls to a constructor of the supplied type.
-
toField
public MethodDelegation toField(java.lang.String name)
Delegates any intercepted method to invoke a non-static
method on the instance of the supplied field. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
name
- The field's name.- Returns:
- A delegation that redirects invocations to a method of the specified field's instance.
-
toField
public MethodDelegation toField(java.lang.String name, FieldLocator.Factory fieldLocatorFactory)
Delegates any intercepted method to invoke a non-static
method on the instance of the supplied field. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
name
- The field's name.fieldLocatorFactory
- The field locator factory to use.- Returns:
- A delegation that redirects invocations to a method of the specified field's instance.
-
toField
public MethodDelegation toField(java.lang.String name, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a non-static
method on the instance of the supplied field. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
name
- The field's name.methodGraphCompiler
- The method graph compiler to use.- Returns:
- A delegation that redirects invocations to a method of the specified field's instance.
-
toField
public MethodDelegation toField(java.lang.String name, FieldLocator.Factory fieldLocatorFactory, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a non-static
method on the instance of the supplied field. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
name
- The field's name.fieldLocatorFactory
- The field locator factory to use.methodGraphCompiler
- The method graph compiler to use.- Returns:
- A delegation that redirects invocations to a method of the specified field's instance.
-
toMethodReturnOf
public MethodDelegation toMethodReturnOf(java.lang.String name)
Delegates any intercepted method to invoke a method on an instance that is returned by a parameterless method of the given name. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
name
- The name of the method that returns the delegation target.- Returns:
- A delegation that redirects invocations to the return value of a method that is declared by the instrumented type.
-
toMethodReturnOf
public MethodDelegation toMethodReturnOf(java.lang.String name, MethodGraph.Compiler methodGraphCompiler)
Delegates any intercepted method to invoke a method on an instance that is returned by a parameterless method of the given name. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method is either public or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if the delegation is targeting the instrumented type.- Parameters:
name
- The name of the method that returns the delegation target.methodGraphCompiler
- The method graph compiler to use.- Returns:
- A delegation that redirects invocations to the return value of a method that is declared by the instrumented type.
-
-