Class ClosureSourceBinding

java.lang.Object
org.apache.groovy.swing.binding.ClosureSourceBinding
All Implemented Interfaces:
SourceBinding

public class ClosureSourceBinding extends Object implements SourceBinding
Uses a closure invocation to compute a source value for a binding.
Since:
Groovy 1.1
  • Constructor Details

    • ClosureSourceBinding

      public ClosureSourceBinding(Closure closure)
      Creates a source binding that invokes the closure with no arguments.
      Parameters:
      closure - the closure used to compute source values
    • ClosureSourceBinding

      public ClosureSourceBinding(Closure closure, Object[] arguments)
      Creates a source binding that invokes the closure with the supplied arguments.
      Parameters:
      closure - the closure used to compute source values
      arguments - the closure arguments to supply
  • Method Details

    • getClosure

      public Closure getClosure()
      Returns the closure used to compute source values.
      Returns:
      the source closure
    • setClosure

      public void setClosure(Closure closure)
      Replaces the closure used to compute source values.
      Parameters:
      closure - the new source closure
    • getSourceValue

      public Object getSourceValue()
      Invokes the configured closure with the current argument list.
      Specified by:
      getSourceValue in interface SourceBinding
      Returns:
      the computed source value
    • setClosureArguments

      public void setClosureArguments(Object[] arguments)
      Replaces the full argument list passed to the closure.
      Parameters:
      arguments - the closure arguments to use
    • setClosureArgument

      public void setClosureArgument(Object argument)
      Replaces the closure arguments with a single argument.
      Parameters:
      argument - the single closure argument to use