Class MethodDelegation.WithCustomProperties

java.lang.Object
net.bytebuddy.implementation.MethodDelegation.WithCustomProperties
Enclosing class:
MethodDelegation

@Enhance public static class MethodDelegation.WithCustomProperties extends Object
A MethodDelegation with custom configuration.
  • Field Details

  • Constructor Details

  • Method Details

    • withResolvers

      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(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

      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

      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

      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

      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(Class<?> type)
      Delegates any intercepted method to invoke a static 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 a static 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(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(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(Object target, 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 the target instance.
      Returns:
      A method delegation that redirects method calls to a static method of the supplied type.
    • to

      public MethodDelegation to(Object target, 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 the target 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(Object target, 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 which target 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(Object target, 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 which target 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(Object target, Type type, 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 which target should be considered. Must be a super type of the target's actual type.
      fieldName - The name of the field that is holding the target instance.
      Returns:
      A method delegation that redirects method calls to a static method of the supplied type.
    • to

      public MethodDelegation to(Object target, Type type, 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 which target should be considered. Must be a super type of the target's actual type.
      fieldName - The name of the field that is holding the target 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(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 which target 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(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 which target 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(Object target, TypeDefinition typeDefinition, 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 which target should be considered. Must be a super type of the target's actual type.
      fieldName - The name of the field that is holding the target instance.
      Returns:
      A method delegation that redirects method calls to a static method of the supplied type.
    • to

      public MethodDelegation to(Object target, TypeDefinition typeDefinition, 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 which target should be considered. Must be a super type of the target's actual type.
      fieldName - The name of the field that is holding the target 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(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(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(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(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(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(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(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.