Package: org.codehaus.groovy.runtime.metaclass

## [Java] Class OwnedMetaClass

- org.codehaus.groovy.runtime.metaclass.OwnedMetaClass

-     public abstract class OwnedMetaClass
      extends DelegatingMetaClass

  An abstract delegating MetaClass that delegates calls to an owner object's MetaClass. Subclasses must provide an owner object via the getOwner() method. This is used in Groovy for features like mixins that require delegation to an owner's metaclass for method and property access.

  This class is for internal use by the Groovy runtime.

- - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class DelegatingMetaClass` | `delegate`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `OwnedMetaClass(MetaClass delegate)` Constructs a new OwnedMetaClass.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public boolean` | `equals(Object obj)` Compares this OwnedMetaClass with another object using the delegate's equality.
    `` | `public Object` | `getAttribute(Object object, String attribute)` Retrieves the value of an attribute on the owner's MetaClass.
    `` | `public Object` | `getAttribute(Class sender, Object receiver, String messageName, boolean useSuper)` Gets an attribute from the owner's MetaClass with caller context.
    `` | `public ClassNode` | `getClassNode()` Returns the AST ClassNode for the owner's class.
    `` | `public MetaMethod` | `getMetaMethod(String name, Object[] args)` Gets a metamethod from the owner's MetaClass by name and argument objects.
    `` | `public MetaMethod` | `getMetaMethod(String name, Class[] argTypes)` Gets a metamethod from the owner's MetaClass by name and argument types.
    `` | `public List<MetaMethod>` | `getMetaMethods()` Returns all metamethods from the owner's MetaClass.
    `` | `public MetaProperty` | `getMetaProperty(String name)` Gets the MetaProperty with the given name from the owner's MetaClass.
    `` | `public List<MetaMethod>` | `getMethods()` Returns all methods from the owner's MetaClass.
    `` | `protected abstract Object` | `getOwner()` Returns the owner object whose MetaClass should be used for delegated operations.
    `` | `protected abstract MetaClass` | `getOwnerMetaClass(Object owner)` Returns the MetaClass of the owner object.
    `` | `public List<MetaProperty>` | `getProperties()` Returns all properties from the owner's MetaClass.
    `` | `public Object` | `getProperty(Object object, String property)` Gets a property value from the owner's MetaClass.
    `` | `public Object` | `getProperty(Class sender, Object receiver, String messageName, boolean useSuper, boolean fromInsideClass)` Gets a property from the owner's MetaClass with caller context.
    `` | `public MetaMethod` | `getStaticMetaMethod(String name, Object[] args)` Gets a static metamethod from the owner's MetaClass by name and argument objects.
    `` | `public MetaMethod` | `getStaticMetaMethod(String name, Class[] argTypes)` Gets a static metamethod from the owner's MetaClass by name and argument types.
    `` | `public Class` | `getTheClass()` Returns the class that this MetaClass represents.
    `` | `public MetaProperty` | `hasProperty(Object obj, String name)` Retrieves the MetaProperty with the given name from the owner's MetaClass.
    `` | `public int` | `hashCode()` Returns the hash code of the delegate MetaClass.
    `` | `public Object` | `invokeConstructor(Object[] arguments)` Invokes a constructor on the owner's MetaClass.
    `` | `public Object` | `invokeMethod(Object object, String methodName, Object arguments)` Invokes a method on the owner's MetaClass with the specified arguments.
    `` | `public Object` | `invokeMethod(Object object, String methodName, Object[] arguments)` Invokes a method on the owner's MetaClass with the specified array of arguments.
    `` | `public Object` | `invokeMethod(Class sender, Object receiver, String methodName, Object[] arguments, boolean isCallToSuper, boolean fromInsideClass)` Invokes a method on the owner's MetaClass with caller context.
    `` | `public Object` | `invokeMissingMethod(Object instance, String methodName, Object[] arguments)` Invokes a missing method on the owner's MetaClass.
    `` | `public Object` | `invokeMissingProperty(Object instance, String propertyName, Object optionalValue, boolean isGetter)` Invokes a missing property on the owner's MetaClass.
    `` | `public Object` | `invokeStaticMethod(Object object, String methodName, Object[] arguments)` Invokes a static method on the owner's MetaClass.
    `` | `public boolean` | `isGroovyObject()` Checks if the owner's class is a GroovyObject.
    `` | `public List<MetaMethod>` | `respondsTo(Object obj, String name, Object[] argTypes)` Returns all metamethods that respond to the given method name and argument types.
    `` | `public List<MetaMethod>` | `respondsTo(Object obj, String name)` Returns all metamethods that respond to the given method name.
    `` | `public int` | `selectConstructorAndTransformArguments(int numberOfConstructors, Object[] arguments)` Selects a constructor and transforms arguments for the owner's metaclass.
    `` | `public void` | `setAttribute(Object object, String attribute, Object newValue)` Sets the value of an attribute on the owner's MetaClass.
    `` | `public void` | `setAttribute(Class sender, Object receiver, String messageName, Object messageValue, boolean useSuper, boolean fromInsideClass)` Sets an attribute on the owner's MetaClass with caller context.
    `` | `public void` | `setProperty(Object object, String property, Object newValue)` Sets a property value on the owner's MetaClass.
    `` | `public void` | `setProperty(Class sender, Object receiver, String messageName, Object messageValue, boolean useSuper, boolean fromInsideClass)` Sets a property on the owner's MetaClass with caller context.
    `` | `public String` | `toString()` Returns a string representation of this OwnedMetaClass.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class DelegatingMetaClass` | `addMetaBeanProperty, addMetaMethod, addNewInstanceMethod, addNewStaticMethod, equals, getAdaptee, getAttribute, getAttribute, getClassNode, getMetaClass, getMetaMethod, getMetaMethods, getMetaProperty, getMethods, getProperties, getProperty, getProperty, getProperty, getStaticMetaMethod, getStaticMetaMethod, getTheClass, hasProperty, hashCode, initialize, invokeConstructor, invokeMethod, invokeMethod, invokeMethod, invokeMethod, invokeMissingMethod, invokeMissingProperty, invokeStaticMethod, isGroovyObject, isModified, pickMethod, respondsTo, respondsTo, selectConstructorAndTransformArguments, setAdaptee, setAttribute, setAttribute, setMetaClass, setProperty, setProperty, setProperty, toString`

- - ### Constructor Detail

    - #### public OwnedMetaClass(MetaClass delegate)

      Constructs a new OwnedMetaClass.

      Parameters:
        `delegate` - the MetaClass to delegate to

  - ### Method Detail

    - #### public boolean equals(Object obj)

      Compares this OwnedMetaClass with another object using the delegate's equality.

      Parameters:
        `obj` - the object to compare with
      Returns:
        true if equal to the delegate

    - #### public Object getAttribute(Object object, String attribute)

      Retrieves the value of an attribute on the owner's MetaClass.

      Parameters:
        `object` - the object (ignored; the owner is used instead)
        `attribute` - the attribute name
      Returns:
        the attribute value

    - #### public Object getAttribute(Class sender, Object receiver, String messageName, boolean useSuper)

      Gets an attribute from the owner's MetaClass with caller context.

      Parameters:
        `sender` - the class making the request
        `receiver` - the receiver object (ignored; the owner is used instead)
        `messageName` - the attribute name
        `useSuper` - whether to use the super method
      Returns:
        the attribute value

    - #### public ClassNode getClassNode()

      Returns the AST ClassNode for the owner's class.

      Returns:
        the ClassNode of the owner's metaclass

    - #### public MetaMethod getMetaMethod(String name, Object[] args)

      Gets a metamethod from the owner's MetaClass by name and argument objects.

      Parameters:
        `name` - the method name
        `args` - the argument objects
      Returns:
        the MetaMethod or null if not found

    - #### public MetaMethod getMetaMethod(String name, Class[] argTypes)

      Gets a metamethod from the owner's MetaClass by name and argument types.

      Parameters:
        `name` - the method name
        `argTypes` - the argument types
      Returns:
        the MetaMethod or null if not found

    - #### public List<MetaMethod> getMetaMethods()

      Returns all metamethods from the owner's MetaClass.

      Returns:
        a list of all metamethods

    - #### public MetaProperty getMetaProperty(String name)

      Gets the MetaProperty with the given name from the owner's MetaClass.

      Parameters:
        `name` - the property name
      Returns:
        the MetaProperty or null if not found

    - #### public List<MetaMethod> getMethods()

      Returns all methods from the owner's MetaClass.

      Returns:
        a list of all methods

    - #### protected abstract Object getOwner()

      Returns the owner object whose MetaClass should be used for delegated operations.

      Returns:
        the owner object

    - #### protected abstract MetaClass getOwnerMetaClass(Object owner)

      Returns the MetaClass of the owner object.

      Parameters:
        `owner` - the owner object
      Returns:
        the owner's MetaClass

    - #### public List<MetaProperty> getProperties()

      Returns all properties from the owner's MetaClass.

      Returns:
        a list of all properties

    - #### public Object getProperty(Object object, String property)

      Gets a property value from the owner's MetaClass.

      Parameters:
        `object` - the object (ignored; the owner is used instead)
        `property` - the property name
      Returns:
        the property value

    - #### public Object getProperty(Class sender, Object receiver, String messageName, boolean useSuper, boolean fromInsideClass)

      Gets a property from the owner's MetaClass with caller context.

      Parameters:
        `sender` - the class making the request
        `receiver` - the receiver object (ignored; the owner is used instead)
        `messageName` - the property name
        `useSuper` - whether to use the super method
        `fromInsideClass` - whether this is called from inside the class
      Returns:
        the property value

    - #### public MetaMethod getStaticMetaMethod(String name, Object[] args)

      Gets a static metamethod from the owner's MetaClass by name and argument objects.

      Parameters:
        `name` - the method name
        `args` - the argument objects
      Returns:
        the MetaMethod or null if not found

    - #### public MetaMethod getStaticMetaMethod(String name, Class[] argTypes)

      Gets a static metamethod from the owner's MetaClass by name and argument types.

      Parameters:
        `name` - the method name
        `argTypes` - the argument types
      Returns:
        the MetaMethod or null if not found

    - #### public Class getTheClass()

      Returns the class that this MetaClass represents.

      Returns:
        the owner's class

    - #### public MetaProperty hasProperty(Object obj, String name)

      Retrieves the MetaProperty with the given name from the owner's MetaClass.

      Parameters:
        `obj` - the object (ignored; the owner is used instead)
        `name` - the property name
      Returns:
        the MetaProperty or null if not found

    - #### public int hashCode()

      Returns the hash code of the delegate MetaClass.

      Returns:
        the hash code

    - #### public Object invokeConstructor(Object[] arguments)

      Invokes a constructor on the owner's MetaClass.

      Parameters:
        `arguments` - the constructor arguments
      Returns:
        the newly constructed instance

    - #### public Object invokeMethod(Object object, String methodName, Object arguments)

      Invokes a method on the owner's MetaClass with the specified arguments.

      Parameters:
        `object` - the object (ignored; the owner is used instead)
        `methodName` - the method name
        `arguments` - the method arguments (as a single object or varargs)
      Returns:
        the method result

    - #### public Object invokeMethod(Object object, String methodName, Object[] arguments)

      Invokes a method on the owner's MetaClass with the specified array of arguments.

      Parameters:
        `object` - the object (ignored; the owner is used instead)
        `methodName` - the method name
        `arguments` - the method arguments as an array
      Returns:
        the method result

    - #### public Object invokeMethod(Class sender, Object receiver, String methodName, Object[] arguments, boolean isCallToSuper, boolean fromInsideClass)

      Invokes a method on the owner's MetaClass with caller context.

      Parameters:
        `sender` - the class making the request
        `receiver` - the receiver object (ignored; the owner is used instead)
        `methodName` - the method name
        `arguments` - the method arguments
        `isCallToSuper` - whether this is a super method call
        `fromInsideClass` - whether this is called from inside the class
      Returns:
        the method result

    - #### public Object invokeMissingMethod(Object instance, String methodName, Object[] arguments)

      Invokes a missing method on the owner's MetaClass.

      Parameters:
        `instance` - the instance (ignored; the owner is used instead)
        `methodName` - the method name that was missing
        `arguments` - the method arguments
      Returns:
        the method result

    - #### public Object invokeMissingProperty(Object instance, String propertyName, Object optionalValue, boolean isGetter)

      Invokes a missing property on the owner's MetaClass.

      Parameters:
        `instance` - the instance (ignored; the owner is used instead)
        `propertyName` - the property name that was missing
        `optionalValue` - the optional value (for setters)
        `isGetter` - whether this is a getter operation
      Returns:
        the property value (or null for setters)

    - #### public Object invokeStaticMethod(Object object, String methodName, Object[] arguments)

      Invokes a static method on the owner's MetaClass.

      Parameters:
        `object` - the class object
        `methodName` - the method name
        `arguments` - the method arguments
      Returns:
        the method result

    - #### public boolean isGroovyObject()

      Checks if the owner's class is a GroovyObject.

      Returns:
        true if the owner's class implements GroovyObject

    - #### public List<MetaMethod> respondsTo(Object obj, String name, Object[] argTypes)

      Returns all metamethods that respond to the given method name and argument types.

      Parameters:
        `obj` - the object (ignored; the owner is used instead)
        `name` - the method name
        `argTypes` - the argument types
      Returns:
        a list of matching metamethods

    - #### public List<MetaMethod> respondsTo(Object obj, String name)

      Returns all metamethods that respond to the given method name.

      Parameters:
        `obj` - the object (ignored; the owner is used instead)
        `name` - the method name
      Returns:
        a list of matching metamethods

    - #### public int selectConstructorAndTransformArguments(int numberOfConstructors, Object[] arguments)

      Selects a constructor and transforms arguments for the owner's metaclass.

      Parameters:
        `numberOfConstructors` - the number of constructors available
        `arguments` - the constructor arguments to transform
      Returns:
        the selected constructor index

    - #### public void setAttribute(Object object, String attribute, Object newValue)

      Sets the value of an attribute on the owner's MetaClass.

      Parameters:
        `object` - the object (ignored; the owner is used instead)
        `attribute` - the attribute name
        `newValue` - the new attribute value

    - #### public void setAttribute(Class sender, Object receiver, String messageName, Object messageValue, boolean useSuper, boolean fromInsideClass)

      Sets an attribute on the owner's MetaClass with caller context.

      Parameters:
        `sender` - the class making the request
        `receiver` - the receiver object (ignored; the owner is used instead)
        `messageName` - the attribute name
        `messageValue` - the new attribute value
        `useSuper` - whether to use the super method
        `fromInsideClass` - whether this is called from inside the class

    - #### public void setProperty(Object object, String property, Object newValue)

      Sets a property value on the owner's MetaClass.

      Parameters:
        `object` - the object (ignored; the owner is used instead)
        `property` - the property name
        `newValue` - the new property value

    - #### public void setProperty(Class sender, Object receiver, String messageName, Object messageValue, boolean useSuper, boolean fromInsideClass)

      Sets a property on the owner's MetaClass with caller context.

      Parameters:
        `sender` - the class making the request
        `receiver` - the receiver object (ignored; the owner is used instead)
        `messageName` - the property name
        `messageValue` - the new property value
        `useSuper` - whether to use the super method
        `fromInsideClass` - whether this is called from inside the class

    - #### public String toString()

      Returns a string representation of this OwnedMetaClass.

      Returns:
        a string describing this metaclass and its delegate