Package: groovy.lang

## [Java] Class Binding

- groovy.lang.Binding

-     public class Binding
      extends GroovyObjectSupport

  Represents the variable bindings of a script which can be altered from outside the script object or created outside of a script and passed into it.

  Binding instances are not supposed to be used in a multithreaded context.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `Binding()` Creates an empty binding.
    `Binding(Map variables)` Creates a binding backed by the supplied variables map.
    `Binding(String[] args)` A helper constructor used in main(String[]) method calls

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public Object` | `getProperty(String property)` Overloaded to make variables appear as bean properties or via the subscript operator
    `` | `public Object` | `getVariable(String name)` Parameters: `name` - the name of the variable to lookup
    `` | `public Map` | `getVariables()` Returns the variables map, creating it on first access.
    `` | `public boolean` | `hasVariable(String name)` Simple check for whether the binding contains a particular variable or not.
    `` | `public void` | `removeVariable(String name)` remove the variable with the specified name
    `` | `public void` | `setProperty(String property, Object newValue)` Overloaded to make variables appear as bean properties or via the subscript operator
    `` | `public void` | `setVariable(String name, Object value)` Sets the value of the given variable

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class GroovyObjectSupport` | `getMetaClass, setMetaClass`

- - ### Constructor Detail

    - #### public Binding()

      Creates an empty binding.

    - #### public Binding(Map variables)

      Creates a binding backed by the supplied variables map.

      Parameters:
        `variables` - the initial variables

    - #### public Binding(String[] args)

      A helper constructor used in main(String[]) method calls

      Parameters:
        `args` - are the command line arguments from a main()

  - ### Method Detail

    - #### public Object getProperty(String property)

      Overloaded to make variables appear as bean properties or via the subscript operator

    - #### public Object getVariable(String name)

      Parameters:
        `name` - the name of the variable to lookup
      Returns:
        the variable value

    - #### public Map getVariables()

      Returns the variables map, creating it on first access.

      Returns:
        the backing variables map

    - #### public boolean hasVariable(String name)

      Simple check for whether the binding contains a particular variable or not.

      Parameters:
        `name` - the name of the variable to check for

    - #### public void removeVariable(String name)

      remove the variable with the specified name

      Parameters:
        `name` - the name of the variable to remove

    - #### public void setProperty(String property, Object newValue)

      Overloaded to make variables appear as bean properties or via the subscript operator

    - #### public void setVariable(String name, Object value)

      Sets the value of the given variable

      Parameters:
        `name` - the name of the variable to set
        `value` - the new value for the given variable