public final class ClosureMetaClass extends MetaClassImpl
The Closure and Class MetaClasses are not replaceable.
This MetaClass is for internal usage only!
MetaClassImpl.Index, MetaClassImpl.MetaConstructor
getPropertyMethod, INVOKE_METHOD_METHOD, invokeMethodMethod, isGroovyObject, isMap, metaMethodIndex, METHOD_MISSING, PROPERTY_MISSING, registry, setPropertyMethod, STATIC_METHOD_MISSING, STATIC_PROPERTY_MISSING, theCachedClass, theClass
Constructor and Description |
---|
ClosureMetaClass(MetaClassRegistry registry,
java.lang.Class theClass) |
Modifier and Type | Method and Description |
---|---|
void |
addMetaBeanProperty(MetaBeanProperty mp)
Adds a new MetaBeanProperty to this MetaClass
|
void |
addMetaMethod(MetaMethod method)
adds a MetaMethod to this class.
|
void |
addNewInstanceMethod(java.lang.reflect.Method method)
adds a new instance method to this MetaClass.
|
void |
addNewStaticMethod(java.lang.reflect.Method method)
adds a new static method to this MetaClass.
|
protected void |
applyPropertyDescriptors(java.beans.PropertyDescriptor[] propertyDescriptors) |
CallSite |
createPogoCallCurrentSite(CallSite site,
java.lang.Class sender,
java.lang.Object[] args) |
CallSite |
createPogoCallSite(CallSite site,
java.lang.Object[] args) |
CallSite |
createPojoCallSite(CallSite site,
java.lang.Object receiver,
java.lang.Object[] args) |
java.lang.Object |
getAttribute(java.lang.Class sender,
java.lang.Object object,
java.lang.String attribute,
boolean useSuper,
boolean fromInsideClass)
Looks up the given attribute (field) on the given object
|
java.util.List<MetaMethod> |
getMetaMethods()
Retrieves a list of MetaMethods held by this class
|
MetaProperty |
getMetaProperty(java.lang.String name)
Returns a MetaProperty for the given name or null if it doesn't exist
|
java.util.List<MetaMethod> |
getMethods()
Retrieves a list of MetaMethods held by the class
|
MetaMethod |
getMethodWithoutCaching(int index,
java.lang.Class sender,
java.lang.String methodName,
java.lang.Class[] arguments,
boolean isCallToSuper) |
java.util.List<MetaProperty> |
getProperties()
Get all the properties defined for this type
|
java.lang.Object |
getProperty(java.lang.Class sender,
java.lang.Object object,
java.lang.String name,
boolean useSuper,
boolean fromInsideClass)
Retrieves a property on the given receiver for the specified arguments.
|
MetaMethod |
getStaticMetaMethod(java.lang.String name,
java.lang.Class[] argTypes) |
MetaMethod |
getStaticMetaMethod(java.lang.String name,
java.lang.Object[] args)
Retrieves a static MetaMethod for the given name and argument values, using the types of the arguments
to establish the chosen MetaMethod
|
void |
initialize()
complete the initialisation process.
|
java.lang.Object |
invokeMethod(java.lang.Class sender,
java.lang.Object object,
java.lang.String methodName,
java.lang.Object[] originalArguments,
boolean isCallToSuper,
boolean fromInsideClass)
Invokes the given method on the object.
|
java.lang.Object |
invokeStaticMethod(java.lang.Object object,
java.lang.String methodName,
java.lang.Object[] arguments)
Invokes a static method on the given Object with the given name and arguments.
|
protected boolean |
isInitialized() |
MetaMethod |
pickMethod(java.lang.String name,
java.lang.Class[] argTypes)
Selects a method by name and argument classes.
|
java.util.List |
respondsTo(java.lang.Object obj,
java.lang.String name)
Returns an object satisfying Groovy truth if the implementing MetaClass responds to
a method with the given name regardless of arguments.
|
java.util.List |
respondsTo(java.lang.Object obj,
java.lang.String name,
java.lang.Object[] argTypes)
Returns an object satisfying Groovy truth if the implementing MetaClass responds to
a method with the given name and arguments types.
|
java.lang.reflect.Constructor |
retrieveConstructor(java.lang.Class[] arguments) |
MetaMethod |
retrieveStaticMethod(java.lang.String methodName,
java.lang.Class[] arguments) |
void |
setAttribute(java.lang.Class sender,
java.lang.Object object,
java.lang.String attribute,
java.lang.Object newValue,
boolean useSuper,
boolean fromInsideClass)
Sets the given attribute (field) on the given object
|
void |
setProperties(java.lang.Object bean,
java.util.Map map)
Sets a number of bean properties from the given Map where the keys are
the String names of properties and the values are the values of the
properties to set
|
void |
setProperty(java.lang.Class sender,
java.lang.Object object,
java.lang.String name,
java.lang.Object newValue,
boolean useSuper,
boolean fromInsideClass)
Sets the property value on an object
|
addMetaMethodToIndex, checkIfGroovyObjectMethod, checkInitalised, chooseMethod, clearInvocationCaches, createConstructorSite, createStaticSite, dropMethodCache, dropStaticMethodCache, findMethodInClassHierarchy, findMixinMethod, findOwnMethod, findPropertyInClassHierarchy, getAdditionalMetaMethods, getAttribute, getAttribute, getClassInfo, getClassNode, getEffectiveGetMetaProperty, getMetaMethod, getMethodWithCaching, getMethodWithoutCaching, getProperty, getRegistry, getSubclassMetaMethods, getSuperClasses, getTheCachedClass, getTheClass, getVersion, hasProperty, incVersion, invokeConstructor, invokeMethod, invokeMethod, invokeMissingMethod, invokeMissingProperty, invokeStaticMissingProperty, isGroovyObject, isModified, onGetPropertyFoundInHierarchy, onInvokeMethodFoundInHierarchy, onMixinMethodFound, onSetPropertyFoundInHierarchy, onSuperMethodFoundInHierarchy, onSuperPropertyFoundInHierarchy, retrieveConstructor, retrieveStaticMethod, selectConstructorAndTransformArguments, setAttribute, setProperty, toString
public ClosureMetaClass(MetaClassRegistry registry, java.lang.Class theClass)
public MetaProperty getMetaProperty(java.lang.String name)
MetaObjectProtocol
getMetaProperty
in interface MetaObjectProtocol
getMetaProperty
in class MetaClassImpl
name
- The name of the MetaPropertyMetaObjectProtocol.getMetaProperty(String)
public java.lang.Object invokeMethod(java.lang.Class sender, java.lang.Object object, java.lang.String methodName, java.lang.Object[] originalArguments, boolean isCallToSuper, boolean fromInsideClass)
MetaClassImpl
invokeMethod
in interface MetaClass
invokeMethod
in class MetaClassImpl
sender
- The java.lang.Class instance that invoked the methodobject
- The object which the method was invoked onmethodName
- The name of the methodoriginalArguments
- The arguments to the methodisCallToSuper
- Whether the method is a call to a super class methodfromInsideClass
- Whether the call was invoked from the inside or the outside of the classpublic void initialize()
MetaClass
initialize
in interface MetaClass
initialize
in class MetaClassImpl
public java.util.List<MetaMethod> getMethods()
MetaClass
getMethods
in interface MetaClass
getMethods
in interface MetaObjectProtocol
getMethods
in class MetaClassImpl
MetaMethod
public java.util.List<MetaMethod> getMetaMethods()
MetaClass
getMetaMethods
in interface MetaClass
getMetaMethods
in class MetaClassImpl
public java.util.List<MetaProperty> getProperties()
MetaClassImpl
getProperties
in interface MetaClass
getProperties
in interface MetaObjectProtocol
getProperties
in class MetaClassImpl
MetaProperty
public MetaMethod pickMethod(java.lang.String name, java.lang.Class[] argTypes)
MetaClass
pickMethod
in interface MetaClass
pickMethod
in class MetaClassImpl
name
- the name of the method to pickargTypes
- the method argumentspublic MetaMethod retrieveStaticMethod(java.lang.String methodName, java.lang.Class[] arguments)
protected boolean isInitialized()
isInitialized
in class MetaClassImpl
public MetaMethod getStaticMetaMethod(java.lang.String name, java.lang.Object[] args)
MetaObjectProtocol
getStaticMetaMethod
in interface MetaObjectProtocol
getStaticMetaMethod
in class MetaClassImpl
name
- The name of the MetaMethodargs
- The argument typesMetaObjectProtocol.getStaticMetaMethod(String, Object[])
public MetaMethod getStaticMetaMethod(java.lang.String name, java.lang.Class[] argTypes)
public java.lang.Object getProperty(java.lang.Class sender, java.lang.Object object, java.lang.String name, boolean useSuper, boolean fromInsideClass)
MetaClass
Retrieves a property on the given receiver for the specified arguments. The sender is the class that is requesting the property from the object. The MetaClass will attempt to establish the method to invoke based on the name and arguments provided.
The isCallToSuper and fromInsideClass help the Groovy runtime perform optimisations on the call to go directly to the super class if necessary
getProperty
in interface MetaClass
getProperty
in class MetaClassImpl
sender
- The java.lang.Class instance that requested the propertyobject
- The Object which the property is being retrieved fromname
- The name of the propertyuseSuper
- Whether the call is to a super class propertyfromInsideClass
- ??public java.lang.Object getAttribute(java.lang.Class sender, java.lang.Object object, java.lang.String attribute, boolean useSuper, boolean fromInsideClass)
MetaClassImpl
getAttribute
in class MetaClassImpl
public void setAttribute(java.lang.Class sender, java.lang.Object object, java.lang.String attribute, java.lang.Object newValue, boolean useSuper, boolean fromInsideClass)
MetaClassImpl
setAttribute
in interface MetaClass
setAttribute
in class MetaClassImpl
sender
- The class of the object that requested the attributeobject
- The instanceattribute
- The name of the attributenewValue
- The value of the attributeuseSuper
- Whether to look-up on the super class or notfromInsideClass
- Whether the call happened from the inside or the outside of a classpublic java.lang.Object invokeStaticMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments)
MetaObjectProtocol
The Object can either be an instance of the class that this MetaObjectProtocol instance applies to or the java.lang.Class instance itself. If a method cannot be invoked a MissingMethodException is will be thrown
invokeStaticMethod
in interface MetaObjectProtocol
invokeStaticMethod
in class MetaClassImpl
object
- An instance of the class returned by the getTheClass() method or the class itselfmethodName
- The name of the methodarguments
- The arguments to the methodMissingMethodException
public void setProperty(java.lang.Class sender, java.lang.Object object, java.lang.String name, java.lang.Object newValue, boolean useSuper, boolean fromInsideClass)
MetaClassImpl
setProperty
in interface MetaClass
setProperty
in class MetaClassImpl
sender
- The java.lang.Class instance that is mutating the propertyobject
- The Object which the property is being set onname
- The name of the propertynewValue
- The new value of the property to setuseSuper
- Whether the call is to a super class propertyfromInsideClass
- ??public MetaMethod getMethodWithoutCaching(int index, java.lang.Class sender, java.lang.String methodName, java.lang.Class[] arguments, boolean isCallToSuper)
public void setProperties(java.lang.Object bean, java.util.Map map)
MetaClassImpl
setProperties
in class MetaClassImpl
public void addMetaBeanProperty(MetaBeanProperty mp)
MetaClassImpl
addMetaBeanProperty
in interface MutableMetaClass
addMetaBeanProperty
in class MetaClassImpl
mp
- The MetaBeanPropertypublic void addMetaMethod(MetaMethod method)
MetaClassImpl
addMetaMethod
in interface MutableMetaClass
addMetaMethod
in class MetaClassImpl
method
- the MetaMethodMetaClassImpl.initialize()
public void addNewInstanceMethod(java.lang.reflect.Method method)
MutableMetaClass
addNewInstanceMethod
in interface MutableMetaClass
addNewInstanceMethod
in class MetaClassImpl
method
- the method to be addedpublic void addNewStaticMethod(java.lang.reflect.Method method)
MutableMetaClass
addNewStaticMethod
in interface MutableMetaClass
addNewStaticMethod
in class MetaClassImpl
method
- the method to be addedpublic java.lang.reflect.Constructor retrieveConstructor(java.lang.Class[] arguments)
retrieveConstructor
in class MetaClassImpl
public CallSite createPojoCallSite(CallSite site, java.lang.Object receiver, java.lang.Object[] args)
createPojoCallSite
in class MetaClassImpl
public CallSite createPogoCallSite(CallSite site, java.lang.Object[] args)
createPogoCallSite
in class MetaClassImpl
public CallSite createPogoCallCurrentSite(CallSite site, java.lang.Class sender, java.lang.Object[] args)
createPogoCallCurrentSite
in class MetaClassImpl
public java.util.List respondsTo(java.lang.Object obj, java.lang.String name, java.lang.Object[] argTypes)
MetaObjectProtocol
Returns an object satisfying Groovy truth if the implementing MetaClass responds to a method with the given name and arguments types.
Note that this method's return value is based on realised methods and does not take into account objects or classes that implement invokeMethod or methodMissing
This method is "safe" in that it will always return a value and never throw an exception
respondsTo
in interface MetaObjectProtocol
respondsTo
in class MetaClassImpl
obj
- The object to inspectname
- The name of the method of interestargTypes
- The argument types to match againstMetaObjectProtocol.respondsTo(Object, String, Object[])
public java.util.List respondsTo(java.lang.Object obj, java.lang.String name)
MetaObjectProtocol
Returns an object satisfying Groovy truth if the implementing MetaClass responds to a method with the given name regardless of arguments. In other words this method will return for foo() and foo(String).
Note that this method's return value is based on realised methods and does not take into account objects or classes that implement invokeMethod or methodMissing
This method is "safe" in that it will always return a value and never throw an exception
respondsTo
in interface MetaObjectProtocol
respondsTo
in class MetaClassImpl
obj
- The object to inspectname
- The name of the method of interestMetaObjectProtocol.respondsTo(Object, String)
protected void applyPropertyDescriptors(java.beans.PropertyDescriptor[] propertyDescriptors)
applyPropertyDescriptors
in class MetaClassImpl