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

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

public class WeakGenericDynamicProperty
extends AbstractDynamicProperty

A generic dyanmic property for any type used a soft hashmap implementation for generic properties registered as global in the MetaClass

Since:
Oct 27, 2005
Author:
Graeme Rocher

Constructor Summary
WeakGenericDynamicProperty(String propertyName, Class type, boolean readOnly)
           
WeakGenericDynamicProperty(String propertyName, Class type, FunctionCallback initialValueGenerator, boolean readOnly)
          Variant that allows supply of a lazy-initialization function for the initial value.
WeakGenericDynamicProperty(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

WeakGenericDynamicProperty

public WeakGenericDynamicProperty(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

WeakGenericDynamicProperty

public WeakGenericDynamicProperty(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

WeakGenericDynamicProperty

public WeakGenericDynamicProperty(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
initialValueGenerator - Callback function which will be called for initial value of 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-2009 The Grails project