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 an instance method to this metaclass.
|
void |
addNewStaticMethod(java.lang.reflect.Method method)
Adds a static method to this metaclass.
|
protected void |
applyPropertyDescriptors(java.beans.PropertyDescriptor[] propertyDescriptors) |
CallSite |
createPogoCallCurrentSite(CallSite site,
java.lang.Class sender,
java.lang.Object[] args)
Create a CallSite
|
CallSite |
createPogoCallSite(CallSite site,
java.lang.Object[] args)
Create a CallSite
|
CallSite |
createPojoCallSite(CallSite site,
java.lang.Object receiver,
java.lang.Object[] args)
Create a CallSite
|
java.lang.Object |
getAttribute(java.lang.Class sender,
java.lang.Object object,
java.lang.String attribute,
boolean useSuper,
boolean fromInsideClass)
Retrieves the value of an attribute (field).
|
java.util.List<MetaMethod> |
getMetaMethods()
Retrieves the 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 the 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 a method on the given receiver for the specified arguments.
|
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.
|
static void |
resetCachedMetaClasses() |
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 an attribute on the given receiver for the specified arguments.
|
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)
Retrieves a property on the given receiver for the specified arguments.
|
addMetaMethodToIndex, checkIfGroovyObjectMethod, checkInitalised, chooseMethod, clearInvocationCaches, createConstructorSite, createErrorMessageForAmbiguity, createStaticSite, createTransformMetaMethod, doChooseMostSpecificParams, dropMethodCache, dropStaticMethodCache, findMethodInClassHierarchy, findMixinMethod, findOwnMethod, findPropertyInClassHierarchy, getAdditionalMetaMethods, getAttribute, getAttribute, getClassInfo, getClassNode, getEffectiveGetMetaProperty, getMetaMethod, getMethodWithCaching, getMethodWithoutCaching, getProperty, getRegistry, getSubclassMetaMethods, getSuperClasses, getTheCachedClass, getTheClass, getVersion, handleMatches, hasCustomInvokeMethod, hasCustomStaticInvokeMethod, 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 static void resetCachedMetaClasses()
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
Invokes a method on the given receiver for the specified arguments. The sender is the class that invoked the method on 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
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 classMetaClass.invokeMethod(Class, Object, String, Object[], boolean, boolean)
public void initialize()
MetaClassImpl
initialize
in interface MetaClass
initialize
in class MetaClassImpl
public java.util.List<MetaMethod> getMethods()
MetaClassImpl
getMethods
in interface MetaClass
getMethods
in interface MetaObjectProtocol
getMethods
in class MetaClassImpl
MetaMethod
public java.util.List<MetaMethod> getMetaMethods()
MetaClassImpl
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)
MetaClassImpl
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
sender
- The class of the object that requested the attributeobject
- The instance the attribute is to be retrieved fromattribute
- The name of the attributeuseSuper
- Whether to look-up on the super class or notfromInsideClass
- Whether the call was invoked from the inside or the outside of the class.public void setAttribute(java.lang.Class sender, java.lang.Object object, java.lang.String attribute, java.lang.Object newValue, boolean useSuper, boolean fromInsideClass)
MetaClassImpl
Sets an attribute on the given receiver for the specified arguments. The sender is the class that is setting the attribute 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
setAttribute
in interface MetaClass
setAttribute
in class MetaClassImpl
sender
- The java.lang.Class instance that is mutating the propertyobject
- The Object which the property is being set onattribute
- The name of the attribute,newValue
- The new value of the attribute to setuseSuper
- Whether the call is to a super class propertyfromInsideClass
- Whether the call was invoked from the inside or the outside of the 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
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 useSuper and fromInsideClass help the Groovy runtime perform optimisations on the call to go directly to the super class if necessary
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
- Whether the call was invoked from the inside or the outside of the class.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)
MetaClassImpl
addNewInstanceMethod
in interface MutableMetaClass
addNewInstanceMethod
in class MetaClassImpl
method
- The method to be addedpublic void addNewStaticMethod(java.lang.reflect.Method method)
MetaClassImpl
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)
MetaClassImpl
createPojoCallSite
in class MetaClassImpl
public CallSite createPogoCallSite(CallSite site, java.lang.Object[] args)
MetaClassImpl
createPogoCallSite
in class MetaClassImpl
public CallSite createPogoCallCurrentSite(CallSite site, java.lang.Class sender, java.lang.Object[] args)
MetaClassImpl
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