public class DelegatingMetaClass
extends Object
implements GroovyObject, MetaClass, MutableMetaClass
MetaClass implementation that forwards all operations to another meta class.
| Constructor and description |
|---|
DelegatingMetaClass(MetaClass delegate)Creates a delegating meta class for the supplied adaptee. |
DelegatingMetaClass(Class theClass)Creates a delegating meta class for the current meta class of the supplied type. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
addMetaBeanProperty(MetaBeanProperty metaBeanProperty)Adds a new MetaBeanProperty to the MetaClass
|
|
public void |
addMetaMethod(MetaMethod metaMethod)Adds a new MetaMethod to the MetaClass
|
|
public void |
addNewInstanceMethod(Method method)adds a new instance method to this MetaClass. Instance methods are able to overwrite the original methods of the class. Calling this method should not be done after initialise was called.
|
|
public void |
addNewStaticMethod(Method method)adds a new static method to this MetaClass. This is only possible as long as initialise was not called.
|
|
public boolean |
equals(Object obj){@inheritDoc} |
|
public MetaClass |
getAdaptee()Returns the wrapped meta class. |
|
public Object |
getAttribute(Object object, String attribute)Retrieves an attribute of an instance of the class returned by the getTheClass() method. What this means is largely down to the MetaClass implementation, however the default case would result in attempt to read a field of the instance.
|
|
public Object |
getAttribute(Class sender, Object receiver, String messageName, boolean useSuper)Retrieves the value of an attribute (field). This method is to support the Groovy runtime and not for general client API usage.
|
|
public ClassNode |
getClassNode()Obtains a reference to the original AST for the MetaClass if it is available at runtime
|
|
public MetaClass |
getMetaClass()Returns the metaclass for a given class.
|
|
public MetaMethod |
getMetaMethod(String name, Object[] args)Retrieves an instance MetaMethod for the given name and argument values, using the types of the argument values to establish the chosen MetaMethod
|
|
public List<MetaMethod> |
getMetaMethods()Retrieves a list of MetaMethods held by this class. This list includes MetaMethods added by groovy.lang.ExpandoMetaClass.
|
|
public MetaProperty |
getMetaProperty(String name)Returns a MetaProperty for the given name or null if it doesn't exist
|
|
public List<MetaMethod> |
getMethods()Retrieves a list of MetaMethods held by the class. This list does not include MetaMethods added by groovy.lang.ExpandoMetaClass.
|
|
public List<MetaProperty> |
getProperties()Retrieves a list of MetaProperty instances that the MetaClass has
|
|
public Object |
getProperty(Object object, String property)Retrieves a property of an instance of the class returned by the getTheClass() method. What this means is largely down to the MetaClass implementation, however the default case would result in an attempt to invoke a JavaBean getter, or if no such getter exists a public field of the instance.
|
|
public Object |
getProperty(Class sender, Object receiver, String messageName, boolean useSuper, boolean fromInsideClass)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
|
|
public Object |
getProperty(String property)Retrieves a property value.
|
|
public 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
|
|
public MetaMethod |
getStaticMetaMethod(String name, Class[] argTypes)Finds a static meta method using explicit parameter types. |
|
public Class |
getTheClass()Retrieves that Java Class that the attached Meta behaviours apply to
|
|
public MetaProperty |
hasProperty(Object obj, String name)Returns true of the implementing MetaClass has a property of the given name Note that this method will only return true for realised properties and does not take into account implementation of getProperty or propertyMissing
|
|
public int |
hashCode(){@inheritDoc} |
|
public void |
initialize()Complete the initialisation process. After this method is called no methods should be added to the metaclass. Invocation of methods or access to fields/properties is forbidden unless this method is called. This method should contain any initialisation code, taking a longer time to complete. An example is the creation of the Reflector. It is suggested to synchronize this method. |
|
public Object |
invokeConstructor(Object[] arguments)Invokes a constructor for the given arguments. The MetaClass will attempt to pick the best argument which matches the types of the objects passed within the arguments array
|
|
public Object |
invokeMethod(Object object, String methodName, Object arguments)Invokes a method on the given Object with the given name and arguments. The MetaClass will attempt to pick the best method for the given name and arguments. If a method cannot be invoked a MissingMethodException will be thrown.
|
|
public Object |
invokeMethod(Object object, String methodName, Object[] arguments)Invokes a method on the given Object with the given name and arguments. The MetaClass will attempt to pick the best method for the given name and arguments. If a method cannot be invoked a MissingMethodException will be thrown.
|
|
public Object |
invokeMethod(Class sender, Object receiver, String methodName, Object[] arguments, boolean isCallToSuper, boolean fromInsideClass)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
|
|
public Object |
invokeMethod(String name, Object args)Invokes the given method.
|
|
public Object |
invokeMissingMethod(Object instance, String methodName, Object[] arguments)Attempts to invoke the methodMissing method otherwise throws a MissingMethodException
|
|
public Object |
invokeMissingProperty(Object instance, String propertyName, Object optionalValue, boolean isGetter)Invokes the propertyMissing method otherwise throws a MissingPropertyException
|
|
public Object |
invokeStaticMethod(Object object, String methodName, Object[] arguments)Invokes a static method on the given Object with the given name and arguments. 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
|
|
public boolean |
isGroovyObject()Indicates whether the wrapped type implements GroovyObject. |
|
public boolean |
isModified()Return whether the MetaClass has been modified or not
|
|
public MetaMethod |
pickMethod(String methodName, Class[] arguments)@deprecated |
|
public List<MetaMethod> |
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. 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
|
|
public List<MetaMethod> |
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. 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
|
|
public int |
selectConstructorAndTransformArguments(int numberOfConstructors, Object[] arguments)Internal method to support Groovy runtime. Not for client usage.
|
|
public void |
setAdaptee(MetaClass adaptee)Replaces the wrapped meta class. |
|
public void |
setAttribute(Object object, String attribute, Object newValue)Sets an attribute of an instance of the class returned by the getTheClass() method. What this means is largely down to the MetaClass implementation, however the default case would result in an attempt to set a field of the instance.
|
|
public void |
setAttribute(Class sender, Object receiver, String messageName, Object messageValue, boolean useSuper, boolean fromInsideClass)Sets the value of an attribute (field). This method is to support the Groovy runtime and not for general client API usage.
|
|
public void |
setMetaClass(MetaClass metaClass)Allows the MetaClass to be replaced with a derived implementation.
|
|
public void |
setProperty(Object object, String property, Object newValue)Sets a property of an instance of the class returned by the getTheClass() method. What this means is largely down to the MetaClass implementation, however the default case would result in an attempt to invoke a JavaBean setter, or if no such setter exists to set a public field of the instance.
|
|
public void |
setProperty(Class sender, Object receiver, String messageName, Object messageValue, boolean useSuper, boolean fromInsideClass)Sets a property on the given receiver for the specified arguments. The sender is the class that is setting 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
|
|
public void |
setProperty(String property, Object newValue)Sets the given property to the new value.
|
|
public String |
toString(){@inheritDoc} |
Wrapped meta class that receives delegated operations.
Creates a delegating meta class for the supplied adaptee.
delegate - the meta class to delegate toCreates a delegating meta class for the current meta class of the supplied type.
theClass - the Groovy type whose meta class should be wrappedAdds a new MetaBeanProperty to the MetaClass
metaBeanProperty - The MetaBeanProperty instanceAdds a new MetaMethod to the MetaClass
metaMethod - The MetaMethod to addadds a new instance method to this MetaClass. Instance methods are able to overwrite the original methods of the class. Calling this method should not be done after initialise was called.
method - the method to be addedadds a new static method to this MetaClass. This is only possible as long as initialise was not called.
method - the method to be added{@inheritDoc}
Returns the wrapped meta class.
Retrieves an attribute of an instance of the class returned by the getTheClass() method.
What this means is largely down to the MetaClass implementation, however the default case would result in attempt to read a field of the instance.
object - An instance of the class returned by the getTheClass() methodattribute - The name of the attribute to retrieve the value forRetrieves the value of an attribute (field). This method is to support the Groovy runtime and not for general client API usage.
sender - The class of the object that requested the attributereceiver - The instancemessageName - The name of the attributeuseSuper - Whether to look-up on the super class or notObtains a reference to the original AST for the MetaClass if it is available at runtime
Returns the metaclass for a given class.
Retrieves an instance MetaMethod for the given name and argument values, using the types of the argument values to establish the chosen MetaMethod
name - The name of the MetaMethodargs - Array containing - 1) the argument values (using which their types are then inferred), or 2) the corresponding argument typesRetrieves a list of MetaMethods held by this class. This list includes MetaMethods added by groovy.lang.ExpandoMetaClass.
Returns a MetaProperty for the given name or null if it doesn't exist
name - The name of the MetaPropertyRetrieves a list of MetaMethods held by the class. This list does not include MetaMethods added by groovy.lang.ExpandoMetaClass.
Retrieves a list of MetaProperty instances that the MetaClass has
Retrieves a property of an instance of the class returned by the getTheClass() method.
What this means is largely down to the MetaClass implementation, however the default case would result in an attempt to invoke a JavaBean getter, or if no such getter exists a public field of the instance.
object - An instance of the class returned by the getTheClass() methodproperty - The name of the property to retrieve the value for
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
sender - The java.lang.Class instance that requested the propertyreceiver - The Object which the property is being retrieved fromproperty - The name of the propertyisCallToSuper - Whether the call is to a super class propertyfromInsideClass - ??Retrieves a property value.
propertyName - the name of the property of interestRetrieves a static MetaMethod for the given name and argument values, using the types of the arguments to establish the chosen MetaMethod
name - The name of the MetaMethodargs - The argument typesFinds a static meta method using explicit parameter types.
name - the method nameargTypes - the parameter types to matchnull if none matchesRetrieves that Java Class that the attached Meta behaviours apply to
Returns true of the implementing MetaClass has a property of the given name
Note that this method will only return true for realised properties and does not take into account implementation of getProperty or propertyMissing
obj - The object to inspectname - The name of the property{@inheritDoc}
Complete the initialisation process. After this method is called no methods should be added to the metaclass. Invocation of methods or access to fields/properties is forbidden unless this method is called. This method should contain any initialisation code, taking a longer time to complete. An example is the creation of the Reflector. It is suggested to synchronize this method.
Invokes a constructor for the given arguments. The MetaClass will attempt to pick the best argument which matches the types of the objects passed within the arguments array
arguments - The arguments to the constructorInvokes a method on the given Object with the given name and arguments. The MetaClass will attempt to pick the best method for the given name and arguments. If a method cannot be invoked a MissingMethodException will be thrown.
object - The instance which the method is invoked onmethodName - The name of the methodarguments - The arguments to the methodInvokes a method on the given Object with the given name and arguments. The MetaClass will attempt to pick the best method for the given name and arguments. If a method cannot be invoked a MissingMethodException will be thrown.
object - The instance which the method is invoked onmethodName - The name of the methodarguments - The arguments to the method
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
sender - The java.lang.Class instance that invoked the methodreceiver - The object which the method was invoked onmethodName - The name of the methodarguments - 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 classInvokes the given method.
name - the name of the method to callargs - the arguments to use for the method call
Attempts to invoke the methodMissing method otherwise throws a MissingMethodException
instance - The instance to invoke methodMissing onmethodName - The name of the methodarguments - The arguments to the methodInvokes the propertyMissing method otherwise throws a MissingPropertyException
instance - The instance of the classpropertyName - The name of the propertyoptionalValue - The value of the property which could be null in the case of a getterisGetter - Whether the missing property event was the result of a getter or a setterInvokes a static method on the given Object with the given name and arguments.
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
object - An instance of the class returned by the getTheClass() method or the class itselfmethodName - The name of the methodarguments - The arguments to the methodIndicates whether the wrapped type implements GroovyObject.
true if the adaptee represents a Groovy object typeReturn whether the MetaClass has been modified or not
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
obj - The object to inspectname - The name of the method of interestargTypes - The argument types to match against
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
obj - The object to inspectname - The name of the method of interestInternal method to support Groovy runtime. Not for client usage.
numberOfConstructors - The number of constructorsarguments - The argumentsReplaces the wrapped meta class.
adaptee - the new meta class to delegate toSets an attribute of an instance of the class returned by the getTheClass() method.
What this means is largely down to the MetaClass implementation, however the default case would result in an attempt to set a field of the instance.
object - An instance of the class returned by the getTheClass() methodattribute - The name of the attribute to setnewValue - The new value of the attributeSets the value of an attribute (field). This method is to support the Groovy runtime and not for general client API usage.
sender - The class of the object that requested the attributereceiver - The instancemessageName - The name of the attributemessageValue - 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 classAllows the MetaClass to be replaced with a derived implementation.
metaClass - the new metaclassSets a property of an instance of the class returned by the getTheClass() method.
What this means is largely down to the MetaClass implementation, however the default case would result in an attempt to invoke a JavaBean setter, or if no such setter exists to set a public field of the instance.
object - An instance of the class returned by the getTheClass() methodproperty - The name of the property to setnewValue - The new value of the property
Sets a property on the given receiver for the specified arguments. The sender is the class that is setting 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
sender - The java.lang.Class instance that is mutating the propertyreceiver - The Object which the property is being set onproperty - The name of the propertyvalue - The new value of the property to setisCallToSuper - Whether the call is to a super class propertyfromInsideClass - Whether the call was invoked from the inside or the outside of the classSets the given property to the new value.
propertyName - the name of the property of interestnewValue - the new value for the property{@inheritDoc}
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.