Package org.codehaus.groovy.runtime.wrappers

# Class GroovyObjectWrapper

java.lang.Object
org.codehaus.groovy.runtime.wrappers.Wrapper
org.codehaus.groovy.runtime.wrappers.GroovyObjectWrapper

All Implemented Interfaces:
  `GroovyObject`

public class GroovyObjectWrapper extends Wrapper
Wraps an existing `GroovyObject` while constraining the type it should present to the runtime.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final GroovyObject`
  `wrapped`
  The wrapped Groovy object.

  ### Fields inherited from class org.codehaus.groovy.runtime.wrappers.Wrapper

  `constrainedType`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GroovyObjectWrapper(GroovyObject wrapped, Class constrainedType)`
  Creates a wrapper for a Groovy object constrained to the supplied type.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected MetaClass`
  `getDelegatedMetaClass()`
  Returns the meta class that should handle GroovyObject operations for the wrapped value.
  `Object`
  `getProperty(String property)`
  Returns a property value from the wrapped Groovy object.
  `protected Object`
  `getWrapped()`
  Returns the object used as the delegation target for meta-class-based operations.
  `Object`
  `invokeMethod(String name, Object args)`
  Invokes a method on the wrapped Groovy object.
  `void`
  `setMetaClass(MetaClass metaClass)`
  Updates the wrapped object's meta class.
  `void`
  `setProperty(String property, Object newValue)`
  Sets a property on the wrapped Groovy object.
  `Object`
  `unwrap()`
  Returns the wrapped value.

  ### Methods inherited from class org.codehaus.groovy.runtime.wrappers.Wrapper

  `getMetaClass, getType`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### wrapped

    protected final GroovyObject wrapped
    The wrapped Groovy object.

- ## Constructor Details

  - ### GroovyObjectWrapper

    public GroovyObjectWrapper(GroovyObject wrapped, Class constrainedType)
    Creates a wrapper for a Groovy object constrained to the supplied type.
    Parameters:
      `wrapped` - the wrapped Groovy object
      `constrainedType` - the type the wrapped object should report

- ## Method Details

  - ### unwrap

    public Object unwrap()
    Returns the wrapped value.
    Specified by:
      `unwrap` in class `Wrapper`
    Returns:
      the underlying value represented by this wrapper

  - ### getProperty

    public Object getProperty(String property)
    Returns a property value from the wrapped Groovy object.
    Parameters:
      `property` - the property name
    Returns:
      the resolved property value

  - ### invokeMethod

    public Object invokeMethod(String name, Object args)
    Invokes a method on the wrapped Groovy object.
    Parameters:
      `name` - the method name
      `args` - the invocation arguments
    Returns:
      the invocation result

  - ### setMetaClass

    public void setMetaClass(MetaClass metaClass)
    Updates the wrapped object's meta class.
    Parameters:
      `metaClass` - the new meta class

  - ### setProperty

    public void setProperty(String property, Object newValue)
    Sets a property on the wrapped Groovy object.
    Parameters:
      `property` - the property name
      `newValue` - the new property value

  - ### getWrapped

    protected Object getWrapped()
    Returns the object used as the delegation target for meta-class-based operations.
    Specified by:
      `getWrapped` in class `Wrapper`
    Returns:
      the underlying wrapped object

  - ### getDelegatedMetaClass

    protected MetaClass getDelegatedMetaClass()
    Returns the meta class that should handle GroovyObject operations for the wrapped value.
    Specified by:
      `getDelegatedMetaClass` in class `Wrapper`
    Returns:
      the delegated meta class