groovy.lang
Class ExpandoMetaConstructor

Handles the ability to use the left shift operator to append new constructors

author:
Graeme Rocher

 
Constructor Summary
ExpandoMetaConstructor()
           
 
Method Summary
void checkIfGroovyObjectMethod(ClosureMetaMethod metaMethod, String methodName)
           Checks if the metaMethod is a method from the GroovyObject interface such as setProperty, getProperty and invokeMethod
String convertPropertyName(String prop)
          
List getExpandoMethods()
           Returns a list of expando MetaMethod instances added to this ExpandoMetaClass
Collection getExpandoProperties()
           Returns a list of MetaBeanProperty instances added to this ExpandoMetaClass
Class getJavaClass()
          
MetaClass getMetaClass()
          
MetaProperty getMetaProperty(String name)
           Looks up an existing MetaProperty by name
List getMethods()
           Overrides the behaviour of parent getMethods() method to make MetaClass aware of added Expando methods
List getProperties()
          
Object getProperty(String property)
          
Object getProperty(Class sender, Object object, String name, boolean useSuper, boolean fromInsideClass)
           Overrides default implementation just in case getProperty method has been overriden by ExpandoMetaClass
Object getProperty(Object object, String name)
           Overrides default implementation just in case getProperty method has been overriden by ExpandoMetaClass
String getPropertyForGetter(String getterName)
           Returns a property name equivalent for the given getter name or null if it is not a getter
String getPropertyForSetter(String setterName)
           Returns a property name equivalent for the given setter name or null if it is not a getter
boolean hasMetaMethod(String name, def args)
           Checks whether a MetaMethod for the given name and arguments exists
boolean hasMetaProperty(String name)
           Returns true if the MetaClass has the given property
boolean hasOverrideGetProperty(String name)
          
Object invokeMethod(String name, Object args)
          
Object invokeMethod(Class sender, Object object, String methodName, def originalArguments, boolean isCallToSuper, boolean fromInsideClass)
           Overrides default implementation just in case invokeMethod has been overriden by ExpandoMetaClass
Object invokeStaticMethod(Object object, String methodName, def arguments)
           Overrides default implementation just in case a static invoke method has been set on ExpandoMetaClass
boolean isGetPropertyMethod(String methodName)
          
boolean isGetter(String name, def args)
           Returns true if the name of the method specified and the number of arguments make it a javabean property
boolean isInvokeMethod(String methodName, ClosureMetaMethod metaMethod)
          
boolean isSetPropertyMethod(String methodName, ClosureMetaMethod metaMethod)
          
boolean isSetter(String name, def args)
          
boolean isValidExpandoProperty(String property)
          
Object leftShift(Closure c)
          
void performOperationOnMetaClass(Callable c)
          
void performRegistryCallbacks()
          
void refreshInheritedMethods(Set modifiedSuperExpandos)
           Called from ExpandoMetaClassCreationHandle in the registry if it exists to setup inheritance handling
void registerBeanProperty(String property, Object newValue)
           Registers a new bean property
void registerBeanPropertyForMethod(MetaMethod metaMethod, String propertyName, boolean getter, boolean isStatic)
          
void registerInstanceMethod(String methodName, Closure callable)
           Registers a new instance method for the given method name and closure on this MetaClass
void registerStaticMethod(String name, Closure callable)
           Registers a new static method for the given method name and closure on this MetaClass
void setMetaClass(MetaClass metaClass)
          
void setProperty(String property, Object newValue)
          
void setProperty(Class sender, Object object, String name, Object newValue, boolean useSuper, boolean fromInsideClass)
           Overrides default implementation just in case setProperty method has been overriden by ExpandoMetaClass
 

Constructor Detail

ExpandoMetaConstructor

ExpandoMetaConstructor()


Method Detail

checkIfGroovyObjectMethod

void checkIfGroovyObjectMethod(ClosureMetaMethod metaMethod, String methodName)
Checks if the metaMethod is a method from the GroovyObject interface such as setProperty, getProperty and invokeMethod
param:
metaMethod The metaMethod instance
param:
methodName The method name
see:
GroovyObject


convertPropertyName

String convertPropertyName(String prop)


getExpandoMethods

public List getExpandoMethods()
Returns a list of expando MetaMethod instances added to this ExpandoMetaClass
return:
the expandoMethods


getExpandoProperties

public Collection getExpandoProperties()
Returns a list of MetaBeanProperty instances added to this ExpandoMetaClass
return:
the expandoProperties


getJavaClass

public Class getJavaClass()
return:
The Java class enhanced by this MetaClass


getMetaClass

public MetaClass getMetaClass()


getMetaProperty

public MetaProperty getMetaProperty(String name)
Looks up an existing MetaProperty by name
param:
name The name of the MetaProperty
return:
The MetaProperty or null if it doesn't exist


getMethods

public List getMethods()
Overrides the behaviour of parent getMethods() method to make MetaClass aware of added Expando methods
see:
MetaObjectProtocol#getMethods()
return:
A list of MetaMethods


getProperties

public List getProperties()


getProperty

public Object getProperty(String property)


getProperty

public Object getProperty(Class sender, Object object, String name, boolean useSuper, boolean fromInsideClass)
Overrides default implementation just in case getProperty method has been overriden by ExpandoMetaClass
see:
MetaClassImpl#getProperty(Class, Object, String, boolean, boolean)


getProperty

public Object getProperty(Object object, String name)
Overrides default implementation just in case getProperty method has been overriden by ExpandoMetaClass
see:
MetaClassImpl#getProperty(Object, String)


getPropertyForGetter

String getPropertyForGetter(String getterName)
Returns a property name equivalent for the given getter name or null if it is not a getter
param:
getterName The getter name
return:
The property name equivalent


getPropertyForSetter

public String getPropertyForSetter(String setterName)
Returns a property name equivalent for the given setter name or null if it is not a getter
param:
setterName The setter name
return:
The property name equivalent


hasMetaMethod

public boolean hasMetaMethod(String name, def args)
Checks whether a MetaMethod for the given name and arguments exists
param:
name The name of the MetaMethod
param:
args The arguments to the meta method
return:
True if the method exists otherwise null


hasMetaProperty

public boolean hasMetaProperty(String name)
Returns true if the MetaClass has the given property
param:
name The name of the MetaProperty
return:
True it exists as a MetaProperty


hasOverrideGetProperty

boolean hasOverrideGetProperty(String name)


invokeMethod

public Object invokeMethod(String name, Object args)


invokeMethod

public Object invokeMethod(Class sender, Object object, String methodName, def originalArguments, boolean isCallToSuper, boolean fromInsideClass)
Overrides default implementation just in case invokeMethod has been overriden by ExpandoMetaClass
see:
MetaClassImpl#invokeMethod


invokeStaticMethod

public Object invokeStaticMethod(Object object, String methodName, def arguments)
Overrides default implementation just in case a static invoke method has been set on ExpandoMetaClass
see:
MetaClassImpl#invokeStaticMethod(Object, String, Object[])


isGetPropertyMethod

boolean isGetPropertyMethod(String methodName)


isGetter

boolean isGetter(String name, def args)
Returns true if the name of the method specified and the number of arguments make it a javabean property
param:
name True if its a Javabean property
param:
args The arguments
return:
True if it is a javabean property method


isInvokeMethod

boolean isInvokeMethod(String methodName, ClosureMetaMethod metaMethod)


isSetPropertyMethod

boolean isSetPropertyMethod(String methodName, ClosureMetaMethod metaMethod)


isSetter

public boolean isSetter(String name, def args)


isValidExpandoProperty

boolean isValidExpandoProperty(String property)


leftShift

public Object leftShift(Closure c)


performOperationOnMetaClass

void performOperationOnMetaClass(Callable c)


performRegistryCallbacks

void performRegistryCallbacks()


refreshInheritedMethods

public void refreshInheritedMethods(Set modifiedSuperExpandos)
Called from ExpandoMetaClassCreationHandle in the registry if it exists to setup inheritance handling
param:
modifiedSuperExpandos A list of modified super ExpandoMetaClass


registerBeanProperty

void registerBeanProperty(String property, Object newValue)
Registers a new bean property
param:
property The property name
param:
newValue The properties initial value


registerBeanPropertyForMethod

void registerBeanPropertyForMethod(MetaMethod metaMethod, String propertyName, boolean getter, boolean isStatic)


registerInstanceMethod

void registerInstanceMethod(String methodName, Closure callable)
Registers a new instance method for the given method name and closure on this MetaClass
param:
methodName The method name
param:
callable The callable Closure


registerStaticMethod

void registerStaticMethod(String name, Closure callable)
Registers a new static method for the given method name and closure on this MetaClass
param:
name The method name
param:
callable The callable Closure


setMetaClass

public void setMetaClass(MetaClass metaClass)


setProperty

public void setProperty(String property, Object newValue)


setProperty

public void setProperty(Class sender, Object object, String name, Object newValue, boolean useSuper, boolean fromInsideClass)
Overrides default implementation just in case setProperty method has been overriden by ExpandoMetaClass
see:
MetaClassImpl#setProperty(Class, Object, String, Object, boolean, boolean)