org.codehaus.groovy.grails.commons.metaclass
Class GenericDynamicProperty

java.lang.Object
  extended by org.codehaus.groovy.grails.commons.metaclass.AbstractDynamicProperty
      extended by org.codehaus.groovy.grails.commons.metaclass.GenericDynamicProperty
All Implemented Interfaces:
DynamicProperty

public class GenericDynamicProperty
extends AbstractDynamicProperty

A generic dyanmic property for any type

Since:
Oct 27, 2005
Author:
Graeme Rocher

Constructor Summary
GenericDynamicProperty(String propertyName, Class type, boolean readOnly)
           
GenericDynamicProperty(String propertyName, Class type, FunctionCallback initialValueGenerator, boolean readOnly)
          Variant that allows supply of a lazy-initialization function for the initial value.
GenericDynamicProperty(String propertyName, Class type, Object initialValue, boolean readOnly)
           
 
Method Summary
 Object get(Object object)
          Call the getter on the given object
 void set(Object object, Object newValue)
          Call the setter on the given object
 
Methods inherited from class org.codehaus.groovy.grails.commons.metaclass.AbstractDynamicProperty
getPropertyName, isPropertyMatch
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericDynamicProperty

public GenericDynamicProperty(String propertyName,
                              Class type,
                              Object initialValue,
                              boolean readOnly)
Parameters:
propertyName - The name of the property
type - The type of the property
initialValue - The initial value of the property
readOnly - True for read-only property

GenericDynamicProperty

public GenericDynamicProperty(String propertyName,
                              Class type,
                              boolean readOnly)
Parameters:
propertyName - The name of the property
type - The type of the property
readOnly - True for read-only property

GenericDynamicProperty

public GenericDynamicProperty(String propertyName,
                              Class type,
                              FunctionCallback initialValueGenerator,
                              boolean readOnly)

Variant that allows supply of a lazy-initialization function for the initial value.

This function is called only on the first access to the property for a given object, unless the function returns null in which case it will be called again if another request is made.

Parameters:
propertyName - The name of the property
type - The type of the property
readOnly - True for read-only property
Method Detail

get

public Object get(Object object)
Description copied from interface: DynamicProperty
Call the getter on the given object

Specified by:
get in interface DynamicProperty
Specified by:
get in class AbstractDynamicProperty
Parameters:
object - The target object
Returns:
The result of the getter

set

public void set(Object object,
                Object newValue)
Description copied from interface: DynamicProperty
Call the setter on the given object

Specified by:
set in interface DynamicProperty
Specified by:
set in class AbstractDynamicProperty
Parameters:
object - The target object
newValue - The new value of the property


Copyright (c) 2005-2006 The Grails project