Package: org.codehaus.groovy.runtime.wrappers

## [Java] Class PojoWrapper

- org.codehaus.groovy.runtime.wrappers.PojoWrapper

-     public class PojoWrapper
      extends Wrapper

  Wraps a plain Java object and routes GroovyObject operations through a delegated MetaClass.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected MetaClass` | `delegate` | The meta class used to dispatch GroovyObject operations to the wrapped object.
    `protected Object` | `wrapped` | The wrapped plain Java object.

  - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class Wrapper` | `constrainedType`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `PojoWrapper(Object wrapped, Class constrainedType)` Creates a wrapper for a plain Java object constrained to the supplied type.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected MetaClass` | `getDelegatedMetaClass()` * Returns the meta class that should handle GroovyObject operations for the * wrapped value. * * Returns: the delegated meta class
    `` | `public Object` | `getProperty(String property)` Returns a property value from the wrapped object using the delegated meta class.
    `` | `protected Object` | `getWrapped()` * Returns the object used as the delegation target for meta-class-based * operations. * * Returns: the underlying wrapped object
    `` | `public Object` | `invokeMethod(String methodName, Object arguments)` Invokes a method on the wrapped object using the delegated meta class.
    `` | `public void` | `setMetaClass(MetaClass metaClass)` Sets the meta class used to dispatch GroovyObject operations for the wrapped object.
    `` | `public void` | `setProperty(String property, Object newValue)` Sets a property on the wrapped object using the delegated meta class.
    `` | `public Object` | `unwrap()` * Returns the wrapped value. * * Returns: the underlying value represented by this wrapper

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Wrapper` | `getDelegatedMetaClass, getMetaClass, getType, getWrapped, unwrap`

- - ### Field Detail

    - #### protected MetaClass delegate

      The meta class used to dispatch GroovyObject operations to the wrapped object.

    - #### protected final Object wrapped

      The wrapped plain Java object.

  - ### Constructor Detail

    - #### public PojoWrapper(Object wrapped, Class constrainedType)

      Creates a wrapper for a plain Java object constrained to the supplied type.

      Parameters:
        `wrapped` - the wrapped object
        `constrainedType` - the type the wrapped object should report

  - ### Method Detail

    - #### protected MetaClass getDelegatedMetaClass()

      * Returns the meta class that should handle GroovyObject operations for the * wrapped value. * *

      Returns:
        the delegated meta class

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

      Returns a property value from the wrapped object using the delegated meta class.

      Parameters:
        `property` - the property name
      Returns:
        the resolved property value

    - #### protected Object getWrapped()

      * Returns the object used as the delegation target for meta-class-based * operations. * *

      Returns:
        the underlying wrapped object

    - #### public Object invokeMethod(String methodName, Object arguments)

      Invokes a method on the wrapped object using the delegated meta class.

      Parameters:
        `methodName` - the method name
        `arguments` - the invocation arguments
      Returns:
        the invocation result

    - #### public void setMetaClass(MetaClass metaClass)

      Sets the meta class used to dispatch GroovyObject operations for the wrapped object.

      Parameters:
        `metaClass` - the meta class to delegate to

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

      Sets a property on the wrapped object using the delegated meta class.

      Parameters:
        `property` - the property name
        `newValue` - the new property value

    - #### public Object unwrap()

      * Returns the wrapped value. * *

      Returns:
        the underlying value represented by this wrapper