AbstractClosureProxy (Grails 6.0.0)

Package: grails.test

## [Java] Class AbstractClosureProxy

- grails.test.AbstractClosureProxy

-     @java.lang.SuppressWarnings({ "serial", "rawtypes" })
      public abstract class AbstractClosureProxy
      extends groovy.lang.Closure

  Skeleton implementation of a wrapper class for closures that allows you to intercept invocations of the closure. The wrapper can be used anywhere that the target closure can be used.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `private groovy.lang.Closure<?>` | `target` |

  - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class groovy.lang.Closure` | `OWNER_FIRST, DELEGATE_FIRST, OWNER_ONLY, DELEGATE_ONLY, TO_SELF, DONE, SKIP, IDENTITY`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `AbstractClosureProxy (groovy.lang.Closure<?> closure)` Creates a new instance that wraps the target closure and sends profiling events to the given profiler log.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public groovy.lang.Closure<?>` | `asWritable()`
    `` | `public java.lang.Object` | `call(java.lang.Object objects)` This is the important one: logs entry and exit of the closure call.
    `` | `protected abstract groovy.lang.Closure<?>` | `createWrapper(groovy.lang.Closure<?> c)` Called when a new instance of the proxy needs to be created for the given closure.
    `` | `public groovy.lang.Closure<?>` | `curry(java.lang.Object objects)`
    `` | `protected abstract void` | `doAfterCall(java.lang.Object[] args)` This method is called after the target closure is invoked.
    `` | `protected abstract void` | `doBeforeCall(java.lang.Object[] args)` This method is called before the target closure is invoked.
    `` | `public boolean` | `equals(java.lang.Object obj)` Compares based on identities, but unlike the standard implementation this one will return `true` if the given object is the target closure for this wrapper as well.
    `` | `public java.lang.Object` | `getDelegate()`
    `` | `public int` | `getDirective()`
    `` | `public int` | `getMaximumNumberOfParameters()`
    `` | `public java.lang.Class<?>[]` | `getParameterTypes()`
    `` | `public java.lang.Object` | `getProperty(java.lang.String property)`
    `` | `public int` | `getResolveStrategy()`
    `` | `public int` | `hashCode()`
    `` | `public boolean` | `isCase(java.lang.Object o)`
    `` | `public void` | `setDelegate(java.lang.Object o)`
    `` | `public void` | `setDirective(int i)`
    `` | `public void` | `setProperty(java.lang.String s, java.lang.Object o)`
    `` | `public void` | `setResolveStrategy(int i)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class groovy.lang.Closure` | `groovy.lang.Closure#andThen(groovy.lang.Closure), groovy.lang.Closure#call([Ljava.lang.Object;), groovy.lang.Closure#call(java.lang.Object), groovy.lang.Closure#call(), groovy.lang.Closure#setDelegate(java.lang.Object), groovy.lang.Closure#leftShift(java.lang.Object), groovy.lang.Closure#leftShift(groovy.lang.Closure), groovy.lang.Closure#memoize(), groovy.lang.Closure#dehydrate(), groovy.lang.Closure#getMaximumNumberOfParameters(), groovy.lang.Closure#setResolveStrategy(int), groovy.lang.Closure#getResolveStrategy(), groovy.lang.Closure#getThisObject(), groovy.lang.Closure#getDirective(), groovy.lang.Closure#setDirective(int), groovy.lang.Closure#isCase(java.lang.Object), groovy.lang.Closure#asWritable(), groovy.lang.Closure#curry([Ljava.lang.Object;), groovy.lang.Closure#curry(java.lang.Object), groovy.lang.Closure#rcurry([Ljava.lang.Object;), groovy.lang.Closure#rcurry(java.lang.Object), groovy.lang.Closure#ncurry(int, [Ljava.lang.Object;), groovy.lang.Closure#ncurry(int, java.lang.Object), groovy.lang.Closure#rightShift(groovy.lang.Closure), groovy.lang.Closure#andThenSelf(), groovy.lang.Closure#andThenSelf(int), groovy.lang.Closure#composeSelf(int), groovy.lang.Closure#composeSelf(), groovy.lang.Closure#memoizeAtMost(int), groovy.lang.Closure#memoizeAtLeast(int), groovy.lang.Closure#memoizeBetween(int, int), groovy.lang.Closure#trampoline(), groovy.lang.Closure#trampoline([Ljava.lang.Object;), groovy.lang.Closure#rehydrate(java.lang.Object, java.lang.Object, java.lang.Object), groovy.lang.Closure#compose(groovy.lang.Closure), groovy.lang.Closure#getDelegate(), groovy.lang.Closure#run(), groovy.lang.Closure#getProperty(java.lang.String), groovy.lang.Closure#clone(), groovy.lang.Closure#getParameterTypes(), groovy.lang.Closure#setProperty(java.lang.String, java.lang.Object), groovy.lang.Closure#getOwner(), groovy.lang.Closure#getMetaClass(), groovy.lang.Closure#setMetaClass(groovy.lang.MetaClass), groovy.lang.Closure#wait(long), groovy.lang.Closure#wait(long, int), groovy.lang.Closure#wait(), groovy.lang.Closure#equals(java.lang.Object), groovy.lang.Closure#toString(), groovy.lang.Closure#hashCode(), groovy.lang.Closure#getClass(), groovy.lang.Closure#notify(), groovy.lang.Closure#notifyAll(), groovy.lang.Closure#invokeMethod(java.lang.String, java.lang.Object)`

- - ### Field Detail

    - #### private groovy.lang.Closure<?> target

  - ### Constructor Detail

    - #### public AbstractClosureProxy(groovy.lang.Closure<?> closure)

      Creates a new instance that wraps the target closure and sends profiling events to the given profiler log.

      Parameters:
        `closure` - The target closure to wrap.

  - ### Method Detail

    - #### @java.lang.Override public groovy.lang.Closure<?> asWritable()

    - #### @java.lang.Override public java.lang.Object call(java.lang.Object objects)

      This is the important one: logs entry and exit of the closure call.

    - #### protected abstract groovy.lang.Closure<?> createWrapper(groovy.lang.Closure<?> c)

      Called when a new instance of the proxy needs to be created for the given closure. Usually the implementation simply creates a new instance of the current class, copying over the existing proxy properties:

              return new MyClosureProxy(c, this.field1, ...)

      Parameters:
        `c` - The closure to wrap/proxy.

    - #### @java.lang.Override public groovy.lang.Closure<?> curry(java.lang.Object objects)

    - #### protected abstract void doAfterCall(java.lang.Object[] args)

      This method is called after the target closure is invoked. It will be triggered whether or not an exception is thrown by the target closure.

      Parameters:
        `args` - The arguments passed to the closure.

    - #### protected abstract void doBeforeCall(java.lang.Object[] args)

      This method is called before the target closure is invoked. This is a passive interceptor, so you cannot prevent the call to the target closure. You can modify the arguments, though, but it's not recommended unless you really know what you're doing.

      Parameters:
        `args` - The arguments passed to the closure.

    - #### @java.lang.Override public boolean equals(java.lang.Object obj)

      Compares based on identities, but unlike the standard implementation this one will return `true` if the given object is the target closure for this wrapper as well.

    - #### @java.lang.Override public java.lang.Object getDelegate()

    - #### @java.lang.Override public int getDirective()

    - #### @java.lang.Override public int getMaximumNumberOfParameters()

    - #### @java.lang.Override public java.lang.Class<?>[] getParameterTypes()

    - #### @java.lang.Override public java.lang.Object getProperty(java.lang.String property)

    - #### @java.lang.Override public int getResolveStrategy()

    - #### @java.lang.Override public int hashCode()

    - #### @java.lang.Override public boolean isCase(java.lang.Object o)

    - #### @java.lang.Override public void setDelegate(java.lang.Object o)

    - #### @java.lang.Override public void setDirective(int i)

    - #### @java.lang.Override public void setProperty(java.lang.String s, java.lang.Object o)

    - #### @java.lang.Override public void setResolveStrategy(int i)