Class MethodCallHook.Builder

  • Enclosing class:
    MethodCallHook

    public static class MethodCallHook.Builder
    extends Object
    Builder for MethodCallHook, defaulting to enabled, priority 100, before-call placement, an unrestricted target and no values passed.
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • hookDescriptor

        public MethodCallHook.Builder hookDescriptor​(HookDescriptor hookDescriptor)
        Sets the method the instrumentation will call.
        Parameters:
        hookDescriptor - the hook method descriptor
        Returns:
        this builder
      • enabled

        public MethodCallHook.Builder enabled​(boolean enabled)
        Sets whether the hook is applied at all.
        Parameters:
        enabled - whether the hook is active
        Returns:
        this builder
      • priority

        public MethodCallHook.Builder priority​(int priority)
        Sets the ordering weight against other hooks on the same site.
        Parameters:
        priority - the priority value
        Returns:
        this builder
      • targetClass

        public MethodCallHook.Builder targetClass​(String targetClass)
        Restricts interception to calls on one class.
        Parameters:
        targetClass - internal name of the class, or null for any class
        Returns:
        this builder
      • targetMethod

        public MethodCallHook.Builder targetMethod​(String targetMethod)
        Restricts interception to one method name.
        Parameters:
        targetMethod - the method name, or null for any method
        Returns:
        this builder
      • targetDescriptor

        public MethodCallHook.Builder targetDescriptor​(String targetDescriptor)
        Restricts interception to one overload.
        Parameters:
        targetDescriptor - the method descriptor, or null for any descriptor
        Returns:
        this builder
      • before

        public MethodCallHook.Builder before​(boolean before)
        Sets whether the hook runs before the call.
        Parameters:
        before - whether to hook the call site entry
        Returns:
        this builder
      • after

        public MethodCallHook.Builder after​(boolean after)
        Sets whether the hook runs after the call.
        Parameters:
        after - whether to hook the call site exit
        Returns:
        this builder
      • passReceiver

        public MethodCallHook.Builder passReceiver​(boolean passReceiver)
        Sets whether the call receiver is passed to the hook.
        Parameters:
        passReceiver - whether to pass the receiver
        Returns:
        this builder
      • passArguments

        public MethodCallHook.Builder passArguments​(boolean passArguments)
        Sets whether the call arguments are passed to the hook as an object array.
        Parameters:
        passArguments - whether to pass the arguments
        Returns:
        this builder
      • passResult

        public MethodCallHook.Builder passResult​(boolean passResult)
        Sets whether the call result is passed to the hook; only meaningful for after-hooks.
        Parameters:
        passResult - whether to pass the result
        Returns:
        this builder
      • passMethodName

        public MethodCallHook.Builder passMethodName​(boolean passMethodName)
        Sets whether the intercepted method name is passed to the hook.
        Parameters:
        passMethodName - whether to pass the method name
        Returns:
        this builder