Package groovy.swing.model

# Class PropertyModel

java.lang.Object
groovy.swing.model.PropertyModel

All Implemented Interfaces:
  `NestedValueModel`, `ValueModel`

public class PropertyModel extends Object implements ValueModel, NestedValueModel
Exposes a named property of another `ValueModel` as its own value model.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PropertyModel(ValueModel sourceModel, String property)`
  Creates a writable property model with `Object` as its declared type.
  `PropertyModel(ValueModel sourceModel, String property, Class type)`
  Creates a writable property model with an explicit declared type.
  `PropertyModel(ValueModel sourceModel, String property, Class type, boolean editable)`
  Creates a property model with explicit type and editability.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getProperty()`
  Returns the property name represented by this model.
  `ValueModel`
  `getSourceModel()`
  Returns the model that supplies the owning object for the bound property.
  `Class`
  `getType()`
  Returns the declared property type.
  `Object`
  `getValue()`
  Reads the current property value from the source object.
  `boolean`
  `isEditable()`
  Indicates whether writes should be forwarded to the source property.
  `void`
  `setValue(Object value)`
  Writes a new value to the property on the current source object.

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

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

- ## Constructor Details

  - ### PropertyModel

    public PropertyModel(ValueModel sourceModel, String property)
    Creates a writable property model with `Object` as its declared type.
    Parameters:
      `sourceModel` - the model that supplies the owning object
      `property` - the property name to access

  - ### PropertyModel

    public PropertyModel(ValueModel sourceModel, String property, Class type)
    Creates a writable property model with an explicit declared type.
    Parameters:
      `sourceModel` - the model that supplies the owning object
      `property` - the property name to access
      `type` - the declared property type

  - ### PropertyModel

    public PropertyModel(ValueModel sourceModel, String property, Class type, boolean editable)
    Creates a property model with explicit type and editability.
    Parameters:
      `sourceModel` - the model that supplies the owning object
      `property` - the property name to access
      `type` - the declared property type
      `editable` - whether writes should be forwarded to the source property

- ## Method Details

  - ### getProperty

    public String getProperty()
    Returns the property name represented by this model.
    Returns:
      the property name

  - ### getSourceModel

    public ValueModel getSourceModel()
    Returns the model that supplies the owning object for the bound property.
    Specified by:
      `getSourceModel` in interface `NestedValueModel`
    Returns:
      the nested source model

  - ### getValue

    public Object getValue()
    Reads the current property value from the source object.
    Specified by:
      `getValue` in interface `ValueModel`
    Returns:
      the current property value, or `null` when the source object is `null`

  - ### setValue

    public void setValue(Object value)
    Writes a new value to the property on the current source object.
    Specified by:
      `setValue` in interface `ValueModel`
    Parameters:
      `value` - the new property value

  - ### getType

    public Class getType()
    Returns the declared property type.
    Specified by:
      `getType` in interface `ValueModel`
    Returns:
      the property type

  - ### isEditable

    public boolean isEditable()
    Indicates whether writes should be forwarded to the source property.
    Specified by:
      `isEditable` in interface `ValueModel`
    Returns:
      `true` when the property model is writable