Package: groovy.lang

## [Java] Class Reference<T>

- groovy.lang.Reference

- All Implemented Interfaces and Traits:
    Serializable

      public class Reference<T>
      extends GroovyObjectSupport
      implements Serializable

  Represents a reference to a value

- - ### Constructor Summary

    Constructors
    Constructor and description
    `Reference()` Creates an empty reference.
    `Reference(T value)` Creates a reference initialized with the supplied value.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public T` | `get()` Returns the referenced value.
    `` | `public Object` | `getProperty(String property)` Retrieves a property value. Parameters: `propertyName` - the name of the property of interest Returns: the given property
    `` | `public Object` | `invokeMethod(String name, Object args)` Invokes the given method. Parameters: `name` - the name of the method to call `args` - the arguments to use for the method call Returns: the result of invoking the method
    `` | `public void` | `set(T value)` Updates the referenced value.
    `` | `public void` | `setProperty(String property, Object newValue)` Sets the given property to the new value. Parameters: `propertyName` - the name of the property of interest `newValue` - the new value for the property

  - ### Inherited Methods Summary

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

- - ### Constructor Detail

    - #### public Reference()

      Creates an empty reference.

    - #### public Reference(T value)

      Creates a reference initialized with the supplied value.

      Parameters:
        `value` - the initial value

  - ### Method Detail

    - #### public T get()

      Returns the referenced value.

      Returns:
        the referenced value

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

      Retrieves a property value.

      Parameters:
        `propertyName` - the name of the property of interest
      Returns:
        the given property

    - #### public Object invokeMethod(String name, Object args)

      Invokes the given method.

      Parameters:
        `name` - the name of the method to call
        `args` - the arguments to use for the method call
      Returns:
        the result of invoking the method

    - #### public void set(T value)

      Updates the referenced value.

      Parameters:
        `value` - the new value

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

      Sets the given property to the new value.

      Parameters:
        `propertyName` - the name of the property of interest
        `newValue` - the new value for the property