public final class ClosureMetaClass extends MetaClassImpl
The Closure and Class MetaClasses are not replaceable.
This MetaClass is for internal usage only!
MetaClassImpl.Index, MetaClassImpl.MetaConstructorgetPropertyMethod, 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,
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(Method method)
Adds an instance method to this metaclass.
|
void |
addNewStaticMethod(Method method)
Adds a static method to this metaclass.
|
protected void |
applyPropertyDescriptors(PropertyDescriptor[] propertyDescriptors) |
CallSite |
createPogoCallCurrentSite(CallSite site,
Class sender,
Object[] args)
Create a CallSite
|
CallSite |
createPogoCallSite(CallSite site,
Object[] args)
Create a CallSite
|
CallSite |
createPojoCallSite(CallSite site,
Object receiver,
Object[] args)
Create a CallSite
|
Object |
getAttribute(Class sender,
Object object,
String attribute,
boolean useSuper,
boolean fromInsideClass)
Retrieves the value of an attribute (field).
|
List<MetaMethod> |
getMetaMethods()
Retrieves the list of MetaMethods held by this class.
|
MetaProperty |
getMetaProperty(String name)
Returns a MetaProperty for the given name or null if it doesn't exist
|
List<MetaMethod> |
getMethods()
Retrieves the list of MetaMethods held by the class.
|
MetaMethod |
getMethodWithoutCaching(int index,
Class sender,
String methodName,
Class[] arguments,
boolean isCallToSuper) |
List<MetaProperty> |
getProperties()
Get all the properties defined for this type
|
Object |
getProperty(Class sender,
Object object,
String name,
boolean useSuper,
boolean fromInsideClass)
Retrieves a property on the given receiver for the specified arguments.
|
MetaMethod |
getStaticMetaMethod(String name,
Class[] argTypes) |
MetaMethod |
getStaticMetaMethod(String name,
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.
|
Object |
invokeMethod(Class sender,
Object object,
String methodName,
Object[] originalArguments,
boolean isCallToSuper,
boolean fromInsideClass)
Invokes a method on the given receiver for the specified arguments.
|
Object |
invokeStaticMethod(Object object,
String methodName,
Object[] arguments)
Invokes a static method on the given Object with the given name and arguments.
|
protected boolean |
isInitialized() |
MetaMethod |
pickMethod(String name,
Class[] argTypes)
Selects a method by name and argument classes.
|
static void |
resetCachedMetaClasses() |
List |
respondsTo(Object obj,
String name)
Returns an object satisfying Groovy truth if the implementing MetaClass responds to
a method with the given name regardless of arguments.
|
List |
respondsTo(Object obj,
String name,
Object[] argTypes)
Returns an object satisfying Groovy truth if the implementing MetaClass responds to
a method with the given name and arguments types.
|
Constructor |
retrieveConstructor(Class[] arguments) |
MetaMethod |
retrieveStaticMethod(String methodName,
Class[] arguments) |
void |
setAttribute(Class sender,
Object object,
String attribute,
Object newValue,
boolean useSuper,
boolean fromInsideClass)
Sets an attribute on the given receiver for the specified arguments.
|
void |
setProperties(Object bean,
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(Class sender,
Object object,
String name,
Object newValue,
boolean useSuper,
boolean fromInsideClass)
Retrieves a property on the given receiver for the specified arguments.
|
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, hasCustomInvokeMethod, hasCustomStaticInvokeMethod, hasProperty, incVersion, invokeConstructor, invokeMethod, invokeMethod, invokeMissingMethod, invokeMissingProperty, invokeStaticMissingProperty, isGroovyObject, isModified, onGetPropertyFoundInHierarchy, onInvokeMethodFoundInHierarchy, onMixinMethodFound, onSetPropertyFoundInHierarchy, onSuperMethodFoundInHierarchy, onSuperPropertyFoundInHierarchy, retrieveConstructor, retrieveStaticMethod, selectConstructorAndTransformArguments, setAttribute, setProperty, toStringpublic ClosureMetaClass(MetaClassRegistry registry, Class theClass)
public static void resetCachedMetaClasses()
public MetaProperty getMetaProperty(String name)
MetaObjectProtocolgetMetaProperty in interface MetaObjectProtocolgetMetaProperty in class MetaClassImplname - The name of the MetaPropertyMetaObjectProtocol.getMetaProperty(String)public Object invokeMethod(Class sender, Object object, String methodName, Object[] originalArguments, boolean isCallToSuper, boolean fromInsideClass)
MetaClassImplInvokes 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 MetaClassinvokeMethod in class MetaClassImplsender - 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()
MetaClassImplinitialize in interface MetaClassinitialize in class MetaClassImplpublic List<MetaMethod> getMethods()
MetaClassImplgetMethods in interface MetaClassgetMethods in interface MetaObjectProtocolgetMethods in class MetaClassImplMetaMethodpublic List<MetaMethod> getMetaMethods()
MetaClassImplgetMetaMethods in interface MetaClassgetMetaMethods in class MetaClassImplpublic List<MetaProperty> getProperties()
MetaClassImplgetProperties in interface MetaClassgetProperties in interface MetaObjectProtocolgetProperties in class MetaClassImplMetaPropertypublic MetaMethod pickMethod(String name, Class[] argTypes)
MetaClassImplpickMethod in interface MetaClasspickMethod in class MetaClassImplname - the name of the method to pickargTypes - the method argumentspublic MetaMethod retrieveStaticMethod(String methodName, Class[] arguments)
protected boolean isInitialized()
isInitialized in class MetaClassImplpublic MetaMethod getStaticMetaMethod(String name, Object[] args)
MetaObjectProtocolgetStaticMetaMethod in interface MetaObjectProtocolgetStaticMetaMethod in class MetaClassImplname - The name of the MetaMethodargs - The argument typesMetaObjectProtocol.getStaticMetaMethod(String, Object[])public MetaMethod getStaticMetaMethod(String name, Class[] argTypes)
public Object getProperty(Class sender, Object object, String name, boolean useSuper, boolean fromInsideClass)
MetaClassRetrieves 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 MetaClassgetProperty in class MetaClassImplsender - 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 Object getAttribute(Class sender, Object object, String attribute, boolean useSuper, boolean fromInsideClass)
MetaClassImplgetAttribute in class MetaClassImplsender - 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(Class sender, Object object, String attribute, Object newValue, boolean useSuper, boolean fromInsideClass)
MetaClassImplSets 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 MetaClasssetAttribute in class MetaClassImplsender - 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 Object invokeStaticMethod(Object object, String methodName, Object[] arguments)
MetaObjectProtocolThe 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 MetaObjectProtocolinvokeStaticMethod in class MetaClassImplobject - An instance of the class returned by the getTheClass() method or the class itselfmethodName - The name of the methodarguments - The arguments to the methodMissingMethodExceptionpublic void setProperty(Class sender, Object object, String name, Object newValue, boolean useSuper, boolean fromInsideClass)
MetaClassImplRetrieves 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 MetaClasssetProperty in class MetaClassImplsender - 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, Class sender, String methodName, Class[] arguments, boolean isCallToSuper)
public void setProperties(Object bean, Map map)
MetaClassImplsetProperties in class MetaClassImplpublic void addMetaBeanProperty(MetaBeanProperty mp)
MetaClassImpladdMetaBeanProperty in interface MutableMetaClassaddMetaBeanProperty in class MetaClassImplmp - The MetaBeanPropertypublic void addMetaMethod(MetaMethod method)
MetaClassImpladdMetaMethod in interface MutableMetaClassaddMetaMethod in class MetaClassImplmethod - the MetaMethodMetaClassImpl.initialize()public void addNewInstanceMethod(Method method)
MetaClassImpladdNewInstanceMethod in interface MutableMetaClassaddNewInstanceMethod in class MetaClassImplmethod - The method to be addedpublic void addNewStaticMethod(Method method)
MetaClassImpladdNewStaticMethod in interface MutableMetaClassaddNewStaticMethod in class MetaClassImplmethod - The method to be addedpublic Constructor retrieveConstructor(Class[] arguments)
retrieveConstructor in class MetaClassImplpublic CallSite createPojoCallSite(CallSite site, Object receiver, Object[] args)
MetaClassImplcreatePojoCallSite in class MetaClassImplpublic CallSite createPogoCallSite(CallSite site, Object[] args)
MetaClassImplcreatePogoCallSite in class MetaClassImplpublic CallSite createPogoCallCurrentSite(CallSite site, Class sender, Object[] args)
MetaClassImplcreatePogoCallCurrentSite in class MetaClassImplpublic List respondsTo(Object obj, String name, Object[] argTypes)
MetaObjectProtocolReturns 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 MetaObjectProtocolrespondsTo in class MetaClassImplobj - The object to inspectname - The name of the method of interestargTypes - The argument types to match againstMetaObjectProtocol.respondsTo(Object, String, Object[])public List respondsTo(Object obj, String name)
MetaObjectProtocolReturns 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 MetaObjectProtocolrespondsTo in class MetaClassImplobj - The object to inspectname - The name of the method of interestMetaObjectProtocol.respondsTo(Object, String)protected void applyPropertyDescriptors(PropertyDescriptor[] propertyDescriptors)
applyPropertyDescriptors in class MetaClassImpl