public class HandleMetaClass
extends DelegatingMetaClass
A delegating meta-class that can replace the meta-class of one instance on demand.
| Fields inherited from class | Fields |
|---|---|
class DelegatingMetaClass |
delegate |
| Constructor and description |
|---|
HandleMetaClass(MetaClass mc)Delegates to mc with no instance attached.
|
HandleMetaClass(MetaClass mc, Object obj)Delegates to mc and records whether obj still needs a per-instance
meta class. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
addMetaBeanProperty(MetaBeanProperty metaBeanProperty) |
|
public void |
addMetaMethod(MetaMethod metaMethod) |
|
public void |
addNewInstanceMethod(Method method) |
|
public void |
addNewStaticMethod(Method method) |
|
public boolean |
equals(Object obj) |
|
public Object |
getProperty(String property) |
|
public void |
initialize() |
|
public Object |
invokeMethod(String name, Object args) |
|
public GroovyObject |
replaceDelegate()Ensures the delegate is an ExpandoMetaClass when a replacement is still pending, then returns that delegate. |
|
public void |
setProperty(String property, Object newValue) |
Delegates to mc with no instance attached.
replaceDelegate() then installs an ExpandoMetaClass on the class.
Equivalent to HandleMetaClass(MetaClass, Object) HandleMetaClass(mc, null).
mc - the meta class to delegate to Delegates to mc and records whether obj still needs a per-instance
meta class. A null obj leaves replacement to the class, as
HandleMetaClass(MetaClass) does. A non-null obj is remembered
when the meta class of obj's class is mc, or when mc is
not an ExpandoMetaClass. Otherwise the instance is treated as already
having its own meta class and replaceDelegate() leaves it alone.
mc - the meta class to delegate toobj - the instance whose meta class may be replaced, or null for the class Ensures the delegate is an ExpandoMetaClass when a replacement is still
pending, then returns that delegate.
With no instance, a delegate that is not already an expando meta class is replaced
by new ExpandoMetaClass(theClass, true, true), initialized, and registered
on the class; an existing expando delegate is registered again.
With a pending instance, a new ExpandoMetaClass(theClass, false, true) is
created, expando methods are copied when the previous delegate is an
ExpandoMetaClass, and the new meta class is set on that instance.
After an instance replacement, further calls do not replace again.
The delegate is cast to GroovyObject.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.